• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.util.Date for any year  RSS feed

 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,


I need to use Date to represent the holiday.

For example Dec 25 is holiday / xmas for any year.

how do I represent it in java.util.Date?

Date for December.25 for any year.....

Could anyone give me some hints?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're asking. Are you looking for the dates of all holidays of a given year? The date of December 25 -which is your example- is always December 25. Can you be more specific as to what your inputs and the associated desired outputs are?
 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for one Date object which could represent any year's Dec 25.

Is it possible? something like ****-12-25 (yyyy-MM-dd), (**** means wildcard for year)

Rgds
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a Calendar, which you initiate with December 25 in a given Year - then you can add one (or any number of Years) to the Calendar object, and get a Date object for the next Year(s).

e.g.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there are any standard Java classes to represent just a day and month. You can use Joda Time, or wait for Java 7 and JSR 310.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!