DEV Community

Discussion on: Data Type Conversions in Java

attacomsian profile image
Atta Author

Yes it requires some ugly preprocessing but it does support popular ISO 8601 date and time formats:

yyyy-MM-dd'T'HH:mm:ssXXX -> 2019-03-30T14:22:15+05:00

//set the timezone to UTC

yyyy-MM-dd'T'HH:mm:ss'Z' -> 2019-03-30T09:22:15Z
yyyyMMdd'T'HHmmss'Z' -> 20190330T092215Z

I updated the tutorial to include these ISO conversions.

Thread Thread
stealthmusic profile image
Jan Wedel

Yeah, I know but there is no single formatter that supports parsing all ISO compliant timestamps. The biggest issue is the time zone options. There „Z“ as well as „+00:00“ and others as well.

Thread Thread
attacomsian profile image
Atta Author

Yeah, timezone options are a bit confusing for developers. Before Java 8, I even used to have a special DateUtils class for handling these ugly conversions at one place.