• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Representing times (was: Date and time in Java )

 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every now and then similar questions pop up. Dates and times seem such a popular subject.
I wonder which types to use to represent the date and time in my javabean. Together they form a timestamp, however the date is part of my business key and the time is not, therefore I wanted to separate them. Currently both are represented by a Date, but this seems somewhat strange.
Related to this, I have lately heard good things about Joda-time, is this worth using and might this help solving my issue?
[ February 17, 2005: Message edited by: Bart Sawyer ]
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lot of methods of the java.util.Date class has been decrepated. Check the apis for GregorianCalendar. It can be used instead of Date class.
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it feels wrong to use a java.util.Date to represent a time without a meaningful date
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bart Sawyer:
I have lately heard good things about Joda-time, is this worth using and might this help solving my issue?

Wow, that looks like a really nice and expressive API. I'd say the only downside is al the code that uses java.util.Date. But for a project that makes heavy use of dates and times, it looks pretty sweet.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tanveer Rameez:
Lot of methods of the java.util.Date class has been decrepated. Check the apis for GregorianCalendar. It can be used instead of Date class.


I would venture to say that the GregorianCalendar and Date classes are NOT completely interchangeable. I think deprecating the Date API was an effort to make Date immutable, somewhat like String is. In fact, I've seen the comparison drawn between String and StringBuffer. In many respects Calendar is to Date as StringBuffer is to String.

Besides this still wouldn't solve the OP's problem since Calendar (or its subclasses, like GregorianCalendar) still store the time AND date together as a single entity.

Layne
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Layne Lund:


Besides this still wouldn't solve the OP's problem since Calendar (or its subclasses, like GregorianCalendar) still store the time AND date together as a single entity.



Indeed, using times without a date does not seem very popular.
 
Grow your own food... or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic