ISO 8601 recommends the following format for a date and time:
2014-12-29T16:11:20+00:00
I'm rather fond of this format since it allows for lexical ordering. But there is a small problem: some file systems don't allow colons in file names (at least not normally). ISO 8601 does allow for omitting the colons, but I would rather have some symbol there than have the numbers run together:
2014-12-29T161120+0000
Does ISO 8601 allow for a symbol other than colons? I couldn't find any indication that it does. If not, is there another well recognized symbol I could use? (Perhaps another standard proposes such a symbol?)
The T is just a literal to separate the date from the time, and the Z means “zero hour offset” also known as “Zulu time” (UTC). If your strings always have a “Z” you can use: SimpleDateFormat format = new SimpleDateFormat( “yyyy-MM-dd'T'HH:mm:ss).
The ISO 8601 notation is today the commonly recommended format of representing date and time as human-readable strings in new plain-text communication protocols and file formats.
There is none.
ISO 8601 only allows for a colon (:
) for separating time components in the extended format:
The basic format is [hh][mm][ss] and the extended format is [hh]:[mm]:[ss].
There is no provision for an alternate extended format.
For combined date and time representations you must use basic format for both date and time or extended format for both date and time representations to comply with ISO 8601.
Examples of ISO 8601 compliant date and time representations:
2020-12-03T15:05:57+00:00 (extended) 2020-12-03T15:05:57Z (extended) 20201203T150557Z (basic)
For maximum compatibility with various operating systems file naming requirements and ISO 8601 compliance I think the last example or something similar should work.
Reference: https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
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