Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DST & Actual Date

 
Anand Bala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find out DST begin and end date in every year(US - CST)? I know DST starts in first Sunday of April and ends in last Sunday of October.

Here is my actual issue.
For a any given date, my method will add given number of days and return the date.

Here is what my code look like...
private static final long DAY_MILLIES = 24*60*60*1000;

long datemillies = fromDate.getTime();
datemillies += (DAY_MILLIES*no_of_days);
return new java.sql.Date(datemillies);

It works fine if this happens within DST or actual time. But I gave DST time (eg.Sep 9 2005) and add some number of days (eg 90 days) which is returning the actual(non-DST) time. Here is the issue. I didn't count the last Sunday of october is 25 hours day. So I am getting the wrong date back.

I am looking on the java api, but no luck yet.

Could someone help me on this. Thanks,
[ August 28, 2005: Message edited by: Anand Bala ]
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you have there is fine because you are working with relatively absolute values -- not a contradiction but a description. All you need is a Calendar: see GregorianCalendar.
 
Anand Bala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rick.
I looked at the GregorianCalendar api and it has some sample code for that. It works.
[ August 28, 2005: Message edited by: Anand Bala ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic