Calendar and Daylight Savings Time

I'm trying to use Calendar objects to store month, day, year information for use in date comparisons/calculations. (e.g. how many days between 1/1/06 and 2/1/06) My program knows nothing of hours, seconds, minutes, etc. and it really doesn't care about them.
That being said, the concept of hour has been cropping up since Calendar automatically throws in an extra hour here and there for DST. In very specific circumstances it can cause an incorrect value.
So to solve this I decided to turn off DST but that seems to be more complicated than it should be. My solution was to create a SimpleTimeZone that has DST disabled and use that as the time zone in my Calendar. Unfortunately, this doesn't work. It now subtracts an hour every now and then (for some strange reason).
So is there any way I'm not seeing in the API to just simply disable DST?
Thanks in advance.

Ok here's a minimal example of what I'm taking about:
import java.util.GregorianCalendar;
import java.text.SimpleDateFormat;
public class Test {
     public static void main( String[] args ) throws Exception {
          SimpleDateFormat format = new SimpleDateFormat( "MM/dd/yy" );
          format.setLenient( false );
          GregorianCalendar testCal1 = new GregorianCalendar();
          testCal1.setTime( format.parse( "10/29/2006" ) ); //One day before DST switch
          GregorianCalendar testCal2 = new GregorianCalendar();
          testCal2.setTime( format.parse( "10/30/2006" ) ); //After DST switch
          long time1 = testCal1.getTimeInMillis();
          long time2 = testCal2.getTimeInMillis();
          System.out.println( time2 - time1 );
}The output of the program is 90000000.
Using some basic math you can calculate that the time between a single day should be 86400000 milliseconds. The difference between the result and the theoretical time between two days is exactly 1 hour.

Similar Messages

  • Has anyone had problems in v5.0a of Iplanet calendar installed on a Sun box with creating events and daylight savings time?

    Events created around 4/6/2002 at 8pm get created with the wrong time (9pm) and there are several other creation and display problems tied to Daylight Savings in April and October. Version 5.1 of the software seems to fix that but we are looking for a fix until we can upgrade. We have been using Windows systems to access the calendar.
    Thanks.

    We have not seen exactly this, but many users appointments are lining up in the wrong time slots. Also, when scheduling, the time display is off by an hour. We have found what looks like a temporary fix.
    We noticed that the problem only affects users who have the start of the week set to Sunday (when daylight savings time started). Setting the week to start on Monday fixed our display problems (you can do it in the users, options section).
    I am placing a support call w/SUN.

  • All-day calendar entries and daylight savings time

    Since changing to daylight savings time, whenever I change the date on an all-day calendar entry, my iPad (but not my iPhone) changes the one-day calendar entry to a two-da calendar entry. How do I correct this?

    Dates are represented internally with a long that represents the number of milliseconds past some fixed point. Timezones do not affect this.
    I'm assuming you're getting your dates as java.sql.Date
    You should then build a Calendar (see GregorianCalendar) and call setTimeZone() with your timezone without daylight savings

  • E-Load/e-ME and Daylight Savings Time Change

    If you are using e-TEST suite versions 8.10 or older, please see the following knowledge base article on updating your JRE for e-Load and e-Manager Enterprise.
    http://qazone.empirix.com/entry.jspa?externalID=201&categoryID=15
    (you must be logged into QAZone to view this link)
    It is recommended that e-Load and e-Manager Enterprise customers update the JRE on their e-Load and e-ME server machines using the SUN JRE patch referenced in the article.
    e-TEST suite version 8.20 which is releasing this week does not require any update.
    Message was edited by: jfernandes

    My problem is that now CFMX 6.1 thinks that it is 8 hours
    later in the day
    than it really is (it is stuck on GMT now) and I am unable to
    get CFMX to
    acknowledge the operating systems clock. :-(
    "GregK" <[email protected]> wrote in message
    news:eord35$5mq$[email protected]..
    The technote for this issue:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=d2ab4470
    has
    another
    link to a technote which addresses null pointer exceptions
    after upgrading
    the
    JVM on CFMX 6.1 systems:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=kb400232
    The hotfix
    described in that technote gives a fix for CFLDAP and
    CFSERVLET tags after
    the
    new JVM is installed.
    The important thing to note is that Adobe feels that
    daylight savings time
    will indeed present a problem for ColdFusion applications.
    Unfortunately,
    the
    problems are not explained in any detail. I can guess that
    functions like
    DateDiff( ) may calculate incorrect values when spanning the
    changed weeks
    of
    daylight savings time. As others have suggested; however,
    simply retrieving
    the system time, i.e. Now( ) function may not be affected as
    long as the
    operating system clock is set correctly.
    Hope that helps.

  • CF MX and Daylight Savings Time Change

    Next year 2007, the Daylight Saving day (chaning the clocks
    for spring and fall) will be changing. The Spring date will be a
    month earlier and the fall date a month later then it has been for
    years.
    How will the Cold Fusion Server for MX 7+ handle this? Will
    it use the server time or use the internal CF Server clock?
    Thanks.

    My problem is that now CFMX 6.1 thinks that it is 8 hours
    later in the day
    than it really is (it is stuck on GMT now) and I am unable to
    get CFMX to
    acknowledge the operating systems clock. :-(
    "GregK" <[email protected]> wrote in message
    news:eord35$5mq$[email protected]..
    The technote for this issue:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=d2ab4470
    has
    another
    link to a technote which addresses null pointer exceptions
    after upgrading
    the
    JVM on CFMX 6.1 systems:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=kb400232
    The hotfix
    described in that technote gives a fix for CFLDAP and
    CFSERVLET tags after
    the
    new JVM is installed.
    The important thing to note is that Adobe feels that
    daylight savings time
    will indeed present a problem for ColdFusion applications.
    Unfortunately,
    the
    problems are not explained in any detail. I can guess that
    functions like
    DateDiff( ) may calculate incorrect values when spanning the
    changed weeks
    of
    daylight savings time. As others have suggested; however,
    simply retrieving
    the system time, i.e. Now( ) function may not be affected as
    long as the
    operating system clock is set correctly.
    Hope that helps.

  • CF MX and Daylight Savings Time

    Hi. We have ColdFusion MX Version 6,1,0,83762 installed on
    our Windows 2003 server. Will we have any issues with the product
    and the Daylight Savings Time coming up on March 11? Is there a
    required patch for this change? Thank you.

    This has been discussed at length in
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 44419&highlight_key=y&keyword1=dst

  • CUE timezone and daylight savings time

    Hi,
    Having issue where CUEs don't seem to be adjusting for daylight savings time. Timezone is set correct to EST but is a hour off because its daylight savings time now. The router and CUE are configured to use same NTP server and router has summertime setting and adjusts for DST fine and has correct time but CUE is a hour behind, like it is not doing DST.
    Were on version 2.2(2) of CUE software.
    This is also in indiana where the laws changed recently so maybe that has something to do with this.
    Any ideas?

    Very likely due to the change in Indiana. A workaround would be to change the timezone to an EST zone that observes DST such as America/Louisville (Eastern Time - Kentucky - Louisville Area).
    Hope this helps.
    Brandon

  • SimpleDateFormat and Daylight Savings Time

    I am trying to parse into a Date "April 15 1999" with "MMM d YYYY" using SimpleDateFormat. This string parses w/out error and the resulting Date is: Thu Apr 15 00:00:00 PST 1999. This is correct in that I am in California. The problem is that 4/15 is Daylight Savings Time in 1999. The getTimeZone result for the parent DateFormat is "SystemV/PST8PDT". I have wrestled with this for over a day now, I admit it, I need help.
    Anyone have any ideas what could be happening here?
    Thanks
    Roger

    When I run BigDaddy's code I get MST for the TZ (which is correct, my default is Mountain TZ and we don't observe DST. By this I surmise that BDLH's default is Pacific TZ and that it observes DST. The following code shows the setting of the TZ to "America/Los_Angeles" and produces the correct result. Windows XP.
    import java.text.*;
    import java.util.*;
    public class PTest {
        public static void main(String[] args) throws ParseException {
            SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy");
            Date dte = sdf.parse("April 15 1999");
            System.out.println(dte);
            SimpleDateFormat sdf2 = new SimpleDateFormat("MMM dd yyyy zzzz");
            sdf2.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
            System.out.println(sdf2.format(dte));
    }

  • COREid and Daylight Savings Time for 2007

    Do COREid or any of its components require any special fix in order to comply or function properly with the new Daylight Savings Time for 2007?
    Background:
    In August of 2005 the United States Congress passed the Energy Policy Act,
    which changes the dates of both the start and end of daylight saving time
    (DST). When this law goes into effect in 2007, DST will start three weeks
    earlier (2:00 A.M. on the second Sunday in March) and will end one week later
    (2:00 A.M. on the first Sunday in November) than what had traditionally
    occurred.
    Thanks,
    Craig
    Message was edited by:
    user557097

    We have experienced many problems with DST and COREid in the past; most of them resulting in hung Access server and unavailability. I don't know if it's because we have components distributed across multiple time zones or what. Our plan is to have someone available at the time change to cycle the services (and maybe the server as a whole) and do a health check after the fact. I hope this helps.
    --Aaron                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Cron job and daylight savings time

    What is the behaviour of cron when the time changes from daylight savings time to standard time and vice versa ?

    This has been discussed at length in
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 44419&highlight_key=y&keyword1=dst

  • Energy Act of 2005 and Daylight Savings Time

    We currently use Sun Studio compilers. We use the embedded tools.h RogueWave libraries. The Energy Act of 2005 changes the dates for Daylight Savings Time starting in 2007. Will there be any patches from Sun to handle this? We currently use RWZoneSimple which is extensible, but we were hoping for an update from Sun.
    Thanks in advance. Sorry if this has been covered, I just couldn't find anything.
    Further Reading:
    http://en.wikipedia.org/wiki/Energy_Policy_Act_of_2005

    The RW Tools.h++ library that comes with Sun Studio has been updated with the new DST rules. I don't think the patches have been released yet.
    If you have a service contract with Sun, you can get a pre-release version of the patch via your support channel.
    Otherwise, check the Sun Studio patch page from time to time
    http://developers.sun.com/sunstudio/downloads/patches/index.jsp
    Look for a C++ compiler patch that includes a fix for bug 6456479.
    RW Tools.h++ does its own DST calculations. Other libraries rely on the Solaris functions in libc. Patches for Solaris are available now as follows:
    S10 - 118833-24(sparc), 118855-19(x86)
    (The fix is included in S10u2.)
    S 9 - 112874-34(sparc), 114432-24(x86)
    S 8 - 108993-62(sparc), 108994-62(x86)

  • IPod clock and daylight savings time...

    I've missed a lunch appointment today because of my iPod!! It looks like a bug to me.
    I arrived in SFO from South Africa and used my iPod clock this morning - it turned out to be an hour slow. When I looked at the clock, I saw that 'daylight saving' was turned off. This seems to be the default if you add a new clock.
    Why on earth would anybody want to have the wrong time when they create a new clock for a new city???
    Has anybody else seen this bug?
    I have checked the 'settings' section and there I had daylight saving turned on, so I don't think this should have happened.

    I think that you're telling me that the bug is worse than I thought!!
    Yes, daylight saving is artificial (all time measurement is, but that's another matter). That isn't the point, though. When I add a new city clock it is because I'm likely to be going there soon, or talking to somebody there, and I want the time to be correct. I have no idea if the place has, or has not, DST, and I don't care - I just want the clock to know and get it right.
    I think you're telling me that the iPod clocks don't download DST tables periodically to make sure that they have them correct (because they change from time to time).
    This means that the iPod clocks are not just useless, but dangerous. There ought to be a warning on the iPod saying - don't use this clock for anything you rely on because it may not know the correct time!!!
    I do hope you are wrong. Surely the clocks check and download the tables every time you connect to iTunes - surely!! Nobody could have been so irresponsible as to offer clocks that don't actually work...

  • Java and daylight savings time

    I just tricked my OS into thinking it is DST but setting the date ahead a bit. After checking, my OS DOES think it is currently DST (with a date of April 3). However, Java doesn't seem to get it!
    For example, take the following two lines of code:
              TimeZone tz = TimeZone.getTimeZone("US/Central");
              System.out.println(tz.getDefault().getDisplayName());
    "Central Standard Time" is displayed. Well, it isn't CST, it's CDT. Why doesn't java see this? Am I doing something wrong?

    Ok, that's fine and dandy. However, when I run the following code (when my machine is in CDT):
              SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-dd z HH:mm:ss");//z means timezone
              SimpleDateFormat format1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");//pattern is arbitrary
              Calendar cal0 = Calendar.getInstance();
              format0.setCalendar(cal0);
              format1.setTimeZone(TimeZone.getTimeZone("US/Central"));
              //Date date = null;
    try {     Date date = format0.parse("2005-01-25 EST 19:15:30"); //zone EST
              String formatted = format1.format(date);
              System.out.println(formatted); }
    The time is formatted and printed as if my computer was in CST. My question is as follows:
    How in the hell do I pass a time from one time zone, and return it formatted according to another timezone taking DST into account? Clearly, the code above does not do that. Java certainly doesn't make DST easy. Oh, and if it's easy to you, perhaps you can explain.

  • Oracle TimeZones and Daylight savings time

    Hi,
    I am working on converting a bunch of old data to a new system. I ran a couple of validation reports for the end user to verify, it seems the times were off. I am in the EST but it seems the times in the db were stored as UTC.
    So when you convert the time from UTC to EST you need to subtract 5 hours but when it is DST you only subtract 4.
    I need to know how to figure out if a time was entered in DST or EST and then I can use something like a decode to decide how much to subtract.
    DST Rules:
    Stone Age -- 2006 First Sunday in April ,Last Sunday in October
    2007 -- present DST Begins 2 a.m. (Second Sunday in March)      DST Ends 2 a.m. (First Sunday in November)
    Here is part of my select statment:
    to_date(to_char(asgn.start_date-5/24,'DD-MON-YYYY')) effective_from,
    I looked at Ask Tom and other sites but could not find a good working example that didn't have a hard coded date. Maybe it is not possible in a select statement.
    Thanks so much for any help you can provide !!!! :)

    >
    I need to know how to figure out if a time was entered in DST or EST
    This seemed to do it:
    >
    I don't see how it possibly can. A DATE datatype does not contain timezone. See the definition of what it contains in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm#i54330
    >
    12
    DATE
    Valid date range from January 1, 4712 BC, to December 31, 9999 AD. The default format is determined explicitly by the NLS_DATE_FORMAT parameter or implicitly by the NLS_TERRITORY parameter. The size is fixed at 7 bytes. This datatype contains the datetime fields YEAR, MONTH, DAY, HOUR, MINUTE, and SECOND. It does not have fractional seconds or a time zone.
    >
    So that DATE value has NO way of knowing what the timezone of the process that entered it was.
    And depending on the meaning of that DATE column you don't even know for sure if the date value represents a date in that process's timezone. I can enter a date representing '01-Jan-2007' but that date doesn't necessarily mean it belongs to my timezone.

  • TimeZone, DateFormat & Daylight Savings time - help please

    Our system holds dates on the database as GMT. I need to display these dates in local times, taking into account time zone differences and daylight savings time. An example:
    DateFormat format = new SimpleDateFormat("HH:mm");
    format.setTimeZone(TimeZone.getTimeZone("Europe/London"));
    GregorianCalendar calendar = new GregorianCalendar(2003,6,31,13,20,25);
    System.out.println(format.format(calendar.getTime()));
    format.setTimeZone(TimeZone.getTimeZone("Europe/Istanbul"));
    System.out.println(format.format(calendar.getTime()));
    This code produces the following output
    13:20
    15:20
    What hasn't been taken into account is that both time zones are in daylight savings time so both dates should be one hour on. TimeZone has all the methods to establish and adjust the date so I'm surprised that the formatter doesn't use these. If I use them manually to adjust the date then everything works OK but I didn't think I'd have to do that. Anyone help me in getting the right results? Is this a bug or do I need to do something different? I'm using JDK 1.4.1
    Many thanks
    Ian

    I still can't get this working how I want. The date that I will be trying to parse will be a GMT date, not a BST date.
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    TimeZone timeZone = TimeZone.getTimeZone("Europe/London");
    Date date = null;
    try {
    date = format.parse("2003-Jul-31 13:20:25");
    } catch (ParseException ex) {
    System.out.println(format.format(date));
    format.setTimeZone(TimeZone.getTimeZone("Europe/Istanbul"));
    System.out.println(format.format(date));
    format.setTimeZone(TimeZone.getTimeZone("Africa/Freetown"));
    System.out.println(format.format(date));
    This is the output
    2003-Jul-31 13:20:25
    2003-Jul-31 15:20:25
    2003-Jul-31 12:20:25
    My desired output is
    2003-Jul-31 14:20:25 GMT +1 hour DST
    2003-Jul-31 16:20:25 GMT +1 hour DST +2 hours time zone difference
    2003-Jul-31 13:20:25 GMT
    Any ideas?
    Cheers
    Ian

Maybe you are looking for

  • Finder problems in 10.9.5

    Hi All Since installing the 10.9.5 update today I have experienced lots of problems with the finder - it won't allow me to select folders or items, and finder windows won't close or minimize.  Everything else seems to be ok but finder being unusable

  • Shall I learn SAP ABAP or SAP Buisiness Obejets.

    Hi, I am currently working Qlikview BI Tool. Now I wanted to learn SAP fine.But here I have problem that shall I learn SAP ABAP or SAP Buisiness Obejets. Which one gives me better career future. Any suggetions appriciates... Thanks.

  • How to do configuration in Integration Builder for Idoc to PI to EDI system?

    Hi Experts. I am working on one interface which is SAP IDOC (DESADV.DELVRY03) >> to>> PI >> to>> EDI system. I am done with all ESR objects, Can anyone help me about how to and what configuration required to be done in Integration Builder? And after

  • From Lightroom to DPS ?

    Hi Guys not sure I can do that but let's ask I have built some books with Lightroom, I am a photographer, so it's just a portfolio of my photos so I would like to know if I might build my App via LR any ideas ? Many thanks, Thierry

  • ADF security at runtime

    Hi All, Is there any posibility to edit resource grant at runtime in adf applicatoin deployed on standalone weblogic with LDAP configured. based on this blog i guess i need to edit system-jzan-data file. here is detailed senario app role created abc