Daylight Saving time: How to identify if a given time is invalid?

Discussion in 'Java' started by Pranav Kantawala, Feb 24, 2004.

  1. Hi,

    I'm writing a web application in Java to schedule tasks at specified
    times. I need to figure out if user has entered a date/time
    combination that is invalid with respect to daylight saving time
    shifts.

    For instance, in US Pacific time, the clock will spring forward from
    1:59am to 3:00am on Sunday, April 4, 2004. Therefore, the time
    interval between 2:00am and 2:59am is not defined.

    If user enters time as, say, 2:30am April 4, I need to figure out that
    this is not a valid time. What is the best way to do this in Java?
    The solution needs to be locale-independent.

    I'm using a Calendar object for date/time representation. I get/set
    time in the object using Calendar.get and Calendar.set methods. If I
    set the time as 2:30am using set method, when I query the date using
    get, I get back 3:30am! So, if what I set in the object is not the
    same as what I get back, it means that the time is not valid. Is this
    a good way to meet the requirement?

    Any insight would be much appreciated.

    Thanks,
    Pranav
     
    Pranav Kantawala, Feb 24, 2004
    #1
    1. Advertising

  2. Pranav Kantawala

    P.Hill Guest

    Please don't cross post.

    Pranav Kantawala wrote:
    >[...]
    > If user enters time as, say, 2:30am April 4, I need to figure out that
    > this is not a valid time. What is the best way to do this in Java?
    > The solution needs to be locale-independent.


    You need to pick SOME locale which uses DLS, otherwise the
    question has no meaning.

    > Any insight would be much appreciated.


    Use SimpleDateFormat which uses its own Calendar object within itself.
    Also use setLenient( false ) and see if that takes care of
    its ability to take 2:30 AM PST on April 4th.

    HTH,
    -Paul
     
    P.Hill, Feb 24, 2004
    #2
    1. Advertising

  3. "P.Hill" <> wrote in message news:<c1en3q$ft9$>...
    > Please don't cross post.


    Crossposting is acceptable if the post is appropriate to all the
    newsgroups included. It is preferable to multiposting because if
    you're using a proper newsreader, you'll only see the post once, even
    if you read both groups.

    Sorry, but crossposting *is* acceptable netiquette, and it's a pet
    peeve of mine when someone says "don't cross post" in situations where
    it is acceptable.
     
    Karl von Laudermann, Feb 24, 2004
    #3
  4. Pranav Kantawala

    P.Hill Guest

    Karl von Laudermann wrote:
    > Sorry, but crossposting *is* acceptable netiquette, and it's a pet
    > peeve of mine when someone says "don't cross post" in situations where
    > it is acceptable.


    Using your logic and assuming the OP post belongs in both, than
    all posts appropriate for .help would also be appropriate for
    ..programmer. If that was the case we wouldn't have .help,
    somehow you've left something out in your logic.

    If I understand the idea of .help, I believe .help is supposed to
    be a separate group, not an overlapping group. It hinges more
    on the intent of the two groups than the idea of crossposting.

    Two wasn't a bad amount of crossposting. All I said was please
    don't.

    cheers,
    -Paul
     
    P.Hill, Feb 24, 2004
    #4
  5. "P.Hill" <> wrote in message news:<c1gjmg$8i9$>...
    > Karl von Laudermann wrote:
    > > Sorry, but crossposting *is* acceptable netiquette, and it's a pet
    > > peeve of mine when someone says "don't cross post" in situations where
    > > it is acceptable.

    >
    > Using your logic and assuming the OP post belongs in both, than
    > all posts appropriate for .help would also be appropriate for
    > .programmer. If that was the case we wouldn't have .help,
    > somehow you've left something out in your logic.


    What I left out of my logic was the same thing you left out of yours:
    an explanation as to why this particular case of crossposting was
    inappropriate. You merely said "don't cross post" as though
    crossposting is never acceptable, i.e. considered bad netiquette. If
    you had specifically stated that the OP's message was inappropriate
    for .programmer in your initial post, I wouldn't have responded.

    However, admittedly I did imply that I thought his crosspost was
    acceptable; I'm not sure whether Java programming questions should be
    verboten in .programmer, just because .help exists. If I have a
    question as to how to implement something, and I'm not a Java beginner
    asking some basic question, what's wrong with asking in .programmer?
    Especially if it could lead to design discussion, rather than a simple
    "here's how you do it" answer.
     
    Karl von Laudermann, Feb 25, 2004
    #5
  6. Pranav Kantawala

    P.Hill Guest

    Karl von Laudermann wrote:
    > I'm not sure whether Java programming questions should be
    > verboten in .programmer, just because .help exists.


    I am sure. Pick one or the other, just not both.

    >what's wrong with asking in .programmer?


    Nothing, I wasn't trying to imply it was to dumb a question, after all
    I answered it, I'm just asking that people try to not even get into the
    two group habit, before you know it they'll be shooting up heroin!
    Ah, I mean they'll be trying maybe a third then ...

    Sorry, I believe a better way to behave is to try a group, if that
    doesn't work try another. Crossposting causess cancer, don't do it.

    cheers,
    -Paul
     
    P.Hill, Feb 25, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Filip Lyncker
    Replies:
    3
    Views:
    754
    Karl Heinz Buchegger
    Apr 5, 2005
  2. Pelle Beckman
    Replies:
    3
    Views:
    490
    Ioannis Vranos
    May 1, 2005
  3. mazdotnet

    Daylight saving time calculation

    mazdotnet, Oct 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    329
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Oct 15, 2006
  4. Harlan Messinger

    Dates, time zones,daylight saving time

    Harlan Messinger, Apr 15, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    1,023
    Eric Isaacs
    Apr 16, 2010
  5. Washington Ratso
    Replies:
    1
    Views:
    65
    Chris “Kwpolska†Warrick
    Apr 3, 2014
Loading...

Share This Page