The SimpleDateFormat class is used to format instances of the Date class as strings using a pattern.
The SimpleDateFormat class is now a legacy class; the DateTimeFormatter is a more up to date alternative as part of the new java.time API.
Enter a Java SimpleDateFormat pattern to see immediately how the current date will be formatted.
Empty input
Java version: 1.8.0_275
Common Issues
- It is important to remember that the SimpleDateFormat class is not thread safe. It will produce unpredictable results if multiple threads try to use the same instance without locking.
- Normally use lower case "y" for the year. Upper case "Y" is the week year and will normally be the same as they year but can differ around new year.
- L vs M: LLLL outputs the stand alone form of the month. This is identical to MMMM in English but in languages such as Finnish, MMMM varies depending on whether a day is is included while LLLL always outputs the month in the standard form.