- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I display Java date as '12/04/2019'
To format and display date like this i.e. Day/Month/Year, you need to set the pattern:
dd/MM/yyyy
At first, set a LocalDate:
LocalDate localDate = LocalDate.now();
Now format and display date as '12/04/2019':
localDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))
Example
import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Demo { public static void main(String[] args) { LocalDate date = LocalDate.now(); System.out.println("Date = "+date); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); System.out.println("Formatted Date = "+date.format(formatter)); } }
Output
Date = 2019-04-12 Formatted Date = 12/04/2019
- Related Articles
- Java Program to format date as Apr 19, 2019, 1:27 PM
- Java Program to format date as Apr 14 2019 01:35 PM IST
- How to format and display date in Java as '201904'
- Show date like 30-04-2020 instead of 2020-04-30 from MySQL database?
- How can I store ‘0000-00-00’ as a date in MySQL?
- How can I save new Date() in MongoDB?
- How can I display MySQL query result vertically?
- Display today’s date in Java with SimpleDateFormat
- Display ISO 8601 standard date in Java
- Display entire date time with milliseconds in Java
- Java Program to display past date from GregorianCalendar
- Java Program to Display current Date and Time
- How do I display the current date and time in an iOS application?
- How do I display the current date and time in an Android application?
- How can I subtract a day from a Python date?

Advertisements