I am using following pattern and date
Date : 13-13-2007
Pattern : dd-MM-yyyy
Output: Sun Jan 13 00:00:00 IST 2008 Or 2008-01-13 00:00:00.0
I was expecting exception here. What can i do to generate exception when given date is inproper.
Create Simple Date Format // Date Format In Java String pattern = "yyyy-MM-dd"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); According to the example above, the String pattern will be used to format dates, and the output will be shown as "yyyy-MM-dd".
DateTimeFormatter is a replacement for the old SimpleDateFormat that is thread-safe and provides additional functionality.
Deprecated. A class for parsing and formatting dates with a given pattern, compatible with the Java 6 API.
Select the dates you want to convert, right click to select Format Cells from context menu. 2. In the Format Cells dialog, under Number tab, select Date from Category list, and then select one format you want to convert to from the right section.
Use DateFormat.setLenient(false)
to tell the DateFormat
/SimpleDateFormat
that you want it to be strict.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With