struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wojciech Ciesielski" <>
Subject RE: a little bit OT: Calendar misbehaviour
Date Mon, 19 Sep 2005 10:57:07 GMT
> I try to parse some input from HTML form with
> Java.sql.Timestamp toReturn;
> SimpleDateFormat dateFormatTime("HH:mm");
> Calendar cal = new GregorianCalendar();
> cal.setTimeInMillis(0);
> cal.setTime(dateFormatTime.parse(timeString));
> toReturn = new Timestamp(cal.getTimeInMillis());
> The point is, that getTimeInMillis() is returning 0 if timeString contains
> only minutes (like "00:20") while cal.getTime().toString returns properly
> "Thu Jan 01 00:10:00 CET 1970".
> Why is it so? How can I initialize that Timestamp with such a string if
> this
> approach does not work?

I know what is the cause of this problem but still don't know how to work
around this... :-(

The problem is that in Poland we have GMT+01 time zone. Therefore default
time zone here is set to GMT +01. And time "Thu Jan 01 00:10:00 CET 1970" is
not translatable to milliseconds because getTimeInMillis() returns time in
UCT and it would be 50 minutes before Epoch...

Can anybody suggest any way of parsing time string to Timestamp? Is using
separate fields for hours and minutes the only solution available?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message