Browse - Programming Tips - What's the most sensible way to display (or save) the date and time?
Keywords: sane, sanity
Q. What's the most sensible way to display (or save) the date and time?
A lot of programs read and write files
that contain the date and time. I can not think of
a better way to represent the date than the standard way:
The link below describes the International Standard Organization's
(ISO 8601) standard.
My programs use this format wherever possible.
Another nice way is:
This isn't immediately sortable but it is readable but all English speakers.
There is no ambiguity on any fields. Of course, its no good for people
who don't read English.
In Java 8 or later:
String time = Instant.now().toString(); // Gives ISO-8601 time