• 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

Date and Daylight Savings Time

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The time I get from the Date method is 1 hour ahead of the time set on my sun box. I am asumming this might have something to do with daylight savings. Does anyone know how I might fix this?

I would have imagined that java Date will pick up system time but this doesn't seem to be the case.

Thanks
Dominique
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look into creating a custom TimeZone that doesn't recognize daylight savings time and setting it onto your dates. Haven't done this personally, but somebody over the wall said they did it. Let us know how it works out!
 
Dominique Ramoney
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm still not getting anywhere with this;
I have tho discovered where the problem lies.
Here is the outpur from a calendar instance;

Calendar = java.util.GregorianCalendar[time=1094178292576,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=Australia/Sydney,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=7,startDay=-1,startDayOfWeek=1,startTime=7200000,endMode=2,endMonth=2,endDay=-1,endDayOfWeek=1,endTime=10800000],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2004,MONTH=8,WEEK_OF_YEAR=36,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=247,DAY_OF_WEEK=6,DAY_OF_W EEK_IN_MONTH=1,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=24,SECOND=52,MILLISECOND=576,ZONE_OFFSET=36000000,DST_OFFSET=3600000]

The problem is startMonth=7, it should be 10.

I cannot find how to change this.
Help Please!!!

 
Dominique Ramoney
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Happy, happy, joy, joy!!

I have found a workable solution!

For anyone who comes across this problem, just put this in your main;

SimpleTimeZone dtz = (SimpleTimeZone) TimeZone.getDefault();
dtz.setStartRule(0,0,0,0);
dtz.setEndRule(0,0,0,0);
TimeZone.setDefault(dtz);

This just gets rid of the daylight saving setting, of course the real solution would be to fix the daylight saving setting but I need to at least have one win today.

Also this requires you to;
import java.util.TimeZone;
import java.util.SimpleTimeZone;



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic