If timezone if the problem, then use SimpleDateFormat.setTimeZone() and
Calendar.setTimeZone() to set the timezones to UTC. That should
eliminate the timezone correction and give you the right number.
Wojciech Ciesielski wrote:
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?
TIA
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Jason Lea