SimpleDateFormat will not work if he/she is starting with LocalDate, which is new in Java 8. From what I can see, you will have to use DateTimeFormatter.
LocalDate localDate = LocalDate.now(); // For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period (AKA full stop) after the day and before the month, you might have to use "dd'.LLLL yyyy".
Answer from ProgrammersBlock on Stack OverflowGeeksforGeeks
geeksforgeeks.org › java › localdate-format-method-in-java
LocalDate format() method in Java - GeeksforGeeks
November 28, 2018 - // Program to illustrate the format() method import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class GfG { public static void main(String[] args) { // Parses the date LocalDate dt = LocalDate.parse("2018-11-01"); System.out.println(dt); // Function call DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/YYYY"); System.out.println(formatter.format(dt)); } }
Top answer 1 of 8
493
SimpleDateFormat will not work if he/she is starting with LocalDate, which is new in Java 8. From what I can see, you will have to use DateTimeFormatter.
LocalDate localDate = LocalDate.now(); // For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
That should print 05 May 1988. To get the period (AKA full stop) after the day and before the month, you might have to use "dd'.LLLL yyyy".
2 of 8
118
It could be short as:
LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
formatting help with date time
You need to call localDate.format(formatter) instead of localDate.toString() More on reddit.com
What kind of data type column you use in SQLite, to store LocalDate?
What do you mean with "Christmas"? In Germany that is the 24th, not the 25th which is nothing special (just a meaningless holiday). More on reddit.com
Using LocalDate as a query parameter with Spring Boot
LocalDate default input conforms with the ISO-8601 format (ie "2015-02-20") but you can provide custom format if required. Spring can bind request parameters to a LocalDate (you need to define what format to use with @DateTimeFormat, even for ISO-8601format). You find a description on how to bind a request parameter to LocalDate at https://www.baeldung.com/spring-date-parameters More on reddit.com
How to persist LocalDateTime values when using MongoDB with Spring
Or you know, don't use local datetimes for things like events which really only need Instants, or OffsetDateTimes A local datetime should only be converted to or from, but never persisted. More on reddit.com
Videos
02:27
Manipulating Dates in Java #12 - LocalDate formatting dates
05:26
#1. Learn About LocalDate of Java in 5 Minutes - YouTube
11:15
Java basics of the LocalDate, LocalTime, LocalDateTime, ZonedDateTime ...
11:06
Java LocalDate - YouTube
18:01
Java Date Classes LocalDate LocalTime LocalDateTime - YouTube
07:20
Convert String to Date in Java | How to convert String to LocalDate ...
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › LocalDate.html
LocalDate (Java Platform SE 8 )
October 20, 2025 - Only objects of type LocalDate are compared, other types return false. To compare the dates of two TemporalAccessor instances, including dates in two different chronologies, use ChronoField.EPOCH_DAY as a comparator. ... A hash code for this date. ... Outputs this date as a String, such as 2007-12-03. The output will be in the ISO-8601 format uuuu-MM-dd. ... Java™ Platform Standard Ed.
How to do in Java
howtodoinjava.com › home › java date time › how to format localdate in java
How to Format LocalDate in Java - HowToDoInJava
March 3, 2024 - LocalDate today = LocalDate.now(); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); String formattedDate = today.format(dateTimeFormatter); //17-02-2022 · Happy Learning !! ... A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies.
Lokalise
lokalise.com › home › java localdate localization tutorial: step by step examples
Java LocalDate localization tutorial: step by step examples
December 19, 2025 - But, our non-localized JavaLocalDateL10n app tried to parse it in the default ISO 8601 date format (YYYY-MM-DD); so obviously, no card order was placed in the system since no date was parsed that day! So, how can our poor JavaLocalDateL10n project overcome this? Well, Java developers have conveniently placed an overloaded LocalDate.parse() method in the LocalDate API just for this use case.
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › time › LocalDate.html
LocalDate (Java SE 21 & JDK 21)
January 20, 2026 - Only objects of type LocalDate are compared, other types return false. To compare the dates of two TemporalAccessor instances, including dates in two different chronologies, use ChronoField.EPOCH_DAY as a comparator. ... A hash code for this date. ... Outputs this date as a String, such as 2007-12-03. The output will be in the ISO-8601 format uuuu-MM-dd.
DigitalOcean
digitalocean.com › community › tutorials › java-8-date-localdate-localdatetime-instant
Java 8 Date - LocalDate, LocalDateTime, Instant | DigitalOcean
August 3, 2022 - Default format of LocalDate=2014-04-28 28::Apr::2014 20140428 Default format of LocalDateTime=2014-04-28T16:25:49.341 28::Apr::2014 16::25::49 20140428 Default format of Instant=2014-04-28T23:25:49.342Z Default format after parsing = 2014-04-27T21:39:48 · Legacy Date/Time classes are used in almost all the applications, so having backward compatibility is a must. That’s why there are several utility methods through which we can convert Legacy classes to new classes and vice versa. package com.journaldev.java8.time; import java.time.Instant; import java.time.LocalDateTime; import java.time.Z
TutorialsPoint
tutorialspoint.com › javatime › javatime_localdate_format.htm
java.time.LocalDate.format() Method Example
package com.tutorialspoint; import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class LocalDateDemo { public static void main(String[] args) { LocalDate date = LocalDate.parse("2017-02-03"); System.out.println(date); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/YYYY"); System.out.println(formatter.format(date)); } }
InfluxData
influxdata.com › home › java date format: a detailed guide
Java Date Format: A Detailed Guide | InfluxData
July 12, 2024 - They offer various methods of formatting and parsing dates without requiring explicit pattern definitions. Here’s an example: import java.time.LocalDate; import java.time.LocalTime; import java.time.LocalDateTime; public class Main { public static void main(String[] args) { // Creating a LocalDate object representing the current date LocalDate currentDate = LocalDate.now(); // Creating a LocalTime object representing the current time LocalTime currentTime = LocalTime.now(); // Creating a LocalDateTime object representing the current date and time LocalDateTime currentDateTime = LocalDateTime.now(); // Printing the current date, time, and date-time System.out.println("Current Date (LocalDate): " + currentDate); System.out.println("Current Time (LocalTime): " + currentTime); System.out.println("Current Date and Time (LocalDateTime): " + currentDateTime); } }
Coderanch
coderanch.com › t › 781266 › java › LocalDate-Format-Failure
LocalDate Format Failure (Java in General forum at Coderanch)
April 25, 2024 - LocalDate doesn't have a format per se, it just has a default string representation when asked for it but the string representation and the internal object state are not one and the same. JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode ...
BeginnersBook
beginnersbook.com › 2017 › 10 › java-convert-localdate-to-date
Java – Convert LocalDate to Date
September 11, 2022 - 1. Getting the default time zone ... Date – local date + atStartOfDay() + default time zone + toInstant() = Date · import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; public class Example { public static void main(String[] args) { //default time zone ZoneId defaultZoneId = ZoneId.systemDefault(); //creating the instance of LocalDate using the day, month, year info LocalDate localDate = LocalDate.of(2016, 8, 19); //local date + atStartOfDay() + default time zone + toInstant() = Date Date date = Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()); //Displaying LocalDate and Date System.out.println("LocalDate is: " + localDate); ...
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
import java.time.LocalDateTime; // import the LocalDateTime class public class Main { public static void main(String[] args) { LocalDateTime myObj = LocalDateTime.now(); System.out.println(myObj); } } ... The "T" in the example above is used to separate the date from the time. You can use the DateTimeFormatter class with the ofPattern() method in the same package to format or parse date-time objects.
Coderanch
coderanch.com › t › 772301 › java › Java-Time-Parsing-Date-Format
Using Java Time Parsing a Date to Specified Format (Java in General forum at Coderanch)
May 1, 2023 - JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility ... Carey Brown wrote:Perhaps I misunderstood, you don't have "2023-05-01" you have a LocalDate containing that date.
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › format › DateTimeFormatter.html
DateTimeFormatter (Java Platform SE 8 )
October 20, 2025 - For example: LocalDate date = LocalDate.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd"); String text = date.format(formatter); LocalDate parsedDate = LocalDate.parse(text, formatter); All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters.
Reddit
reddit.com › r/javahelp › formatting help with date time
r/javahelp on Reddit: formatting help with date time
April 14, 2021 -
i need to formate 11.12.2018 but i am getting 11-12-2018
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM.dd.yyyy");
String date = "11.12.2018";
//convert String to LocalDate
LocalDate localDate = LocalDate.parse(date, formatter);
System.out.println(localDate.toString());
Top answer 1 of 3
3
You need to call localDate.format(formatter) instead of localDate.toString()
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
Studytonight
studytonight.com › java-examples › java-localdate-format-method-with-examples
Java LocalDate format() Method with Examples - Studytonight
June 15, 2020 - Lets take an example to format a date, here we are using ofPattern() method to specify format pattern and the call format() method on it. It returns a date string. import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class DateDemo { public static void main(String[] args){ // Take a date LocalDate date = LocalDate.parse("2018-02-03"); // Displaying date System.out.println("Date : "+date); // Formatting Date DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/YYYY"); String localDate = formatter.format(date); System.out.println("Date2 : "+localDate); } }