I have some data which has date mentioned as "2013-06-30 00:00:00+00:00". I checked the different date formats , however was not able to find this one. Can someone please help ?
As for your question about "what format" this is, technically this format is an optional variation of ISO 8601. The standard allows the T
to be replaced with a SPACE with mutual agreement between the communicating parties.
The use of a SPACE may make the string more readable by humans where proper numeric-savvy fonts are lacking. But strictly speaking this SPACE version is not standard and so the T
should be included when exchanging data between systems or when serializing data as text.
Other answers are correct. Here is an easy alternative for parsing.
Your input string nearly complies with the standard ISO 8601 formats. Replace the SPACE in the middle with a T
to comply fully.
String input = "2013-06-30 00:00:00+00:00".replace( " " , "T" );
The java.time classes supplant the troublesome old legacy date-time classes. These newer classes support ISO 8601 formats by default when parsing/generatihng strings.
OffsetDateTime odt = OffsetDateTime.parse( input );
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.
This is an ISO 8601 formatted date with the T
omitted between the date and time (see: In an ISO 8601 date, is the T character mandatory?)
I guess it should be YYYY-MM-DD 00:00:00+0000
instead of YYYY-MM-DD 00:00:00+00:00
.
This format is yyyy-MM-dd HH:mm:ss.SSSZ
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
Date date = new Date();
System.out.println(dateFormat.format(date));
Other different Date formats are
yyyy-MM-dd 1969-12-31
yyyy-MM-dd 1970-01-01
yyyy-MM-dd HH:mm 1969-12-31 16:00
yyyy-MM-dd HH:mm 1970-01-01 00:00
yyyy-MM-dd HH:mmZ 1969-12-31 16:00-0800
yyyy-MM-dd HH:mmZ 1970-01-01 00:00+0000
yyyy-MM-dd HH:mm:ss.SSSZ 1969-12-31 16:00:00.000-0800
yyyy-MM-dd HH:mm:ss.SSSZ 1970-01-01 00:00:00.000+0000
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1969-12-31T16:00:00.000-0800
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1970-01-01T00:00:00.000+0000
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