• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why are Java Dates calculated in milliseconds?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We all know Java Dates are calculated in milliseconds, but why is it so? Why not in the straightforward dd-mm-yyyy or other date formats?

In what format is it recommended to persist time based values? Appreciate your valuable inputs.

Thanks.

AC
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Unix was created they decided that they were going to measure time in milliseconds, and most languages/file systems have followed suit. The current time is the # of seconds since midnight January 1, 1970. It is usually referred to as unix time.

P.S - If you still want more information, there is a pretty interesting wikipedia article about this topic
http://en.wikipedia.org/wiki/Unix_time


Hunter
 
Ranch Hand
Posts: 43
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also just think that you save the date in any date format and you need to make the diffrence between two dates or even compare them. You should go trough year, month, day... until you see the diffrence. With milliseconds it's much simpler.
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhishek Java Chaturvedi wrote:Why not in the straightforward dd-mm-yyyy or other date formats?



That's just a representation of a date. The same date can be represented in, say, the christian or the islamic calendar. It is still the same point in time, but looking quite different.

Then there is the problem that with your representation there are points in time with the same representation but different meaning: switching from daylight savings time to normal time leaves one hour that is represented by the same textual representation but certainly must be handled different by software (leads to 'creative' solutions like SAP time or ignorance like Quartz scheduler).
 
Abhishek Java Chaturvedi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you everyone for your inputs.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic