Date: 1998jan12
Keywords: sane, sanity
Q. What's the most sensible way to display (or save) the date and time?
A.
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:
YYYY-MM-DD HH:MM:SS
The link below describes the International Standard Organization's
(ISO 8601) standard.
My programs use this format wherever possible.
More info
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
---
Another nice way is:
YYYYMMMDD
eg:
1998jan12
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