Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What system default date format to use?

I'm setting the standards for our application.

I've been wondering, what default date format should I choose to use ?

It should be:

  • Internationalization & timezone aware, the format should be able to represent user local time
  • Can be efficiently parsed by SimpleDataFormat (or alike, jdk classes only)
  • Programming Language agnostic (can parse in java, python, god forbid C++ :) and co.)
  • Preferably ISO based or other accepted standard
  • Easy to communicate over HTTP (Should such need arises, JSON or YAML or something in this nature)
  • Can represent time down to seconds resolution (the more precise the better, micro seconds if possible).
  • Human readable is a plus but not required
  • Compact is a plus but not required

Thank you,
Maxim.

like image 432
Maxim Veksler Avatar asked Jan 27 '11 21:01

Maxim Veksler


People also ask

What is the default format for date?

Date format is MM/DD/CCYY where MM represents a two-digit month, DD represents a two-digit day of the month, CC represents a two-digit century, and YY represents a two-digit year. The date separator may be one of the following characters: '/', '-' or ','. This is the default date format.

What is the default date format in Windows?

By default, Microsoft Windows 10 and 11 use dd/mm/yyyy for dates and a 12-hour format for time.

What is the default date system in Excel?

By default, Microsoft Excel for Windows uses the 1900 date system. The 1900 date system enables better compatibility between Excel and other spreadsheet programs, such as Lotus 1-2-3, that are designed to run under MS-DOS or Microsoft Windows.


2 Answers

yyyy-MM-ddThh:mmZ (See ISO 8601) You can add seconds, etc

You can read it easily, it will not be a problem for SimpleDateFormat.

like image 84
jny Avatar answered Sep 17 '22 11:09

jny


The most canonical and standard form is probably "Unix Time": The number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970.

If you set that as the default time-format you can easily parse it, store it in memory, write it to disk, easily communicate it over HTTP and so on. It is also definitely an accepted standard, and in a sense it is "time-zone aware", since it is well-defined regardless of time-zones.

(This is the format in which I always store all my time stamps; in databases, in memory, on disk, ...)

like image 33
aioobe Avatar answered Sep 21 '22 11:09

aioobe