P
Pranav Kantawala
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
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