You can try use the SimpleDateFormat class in java.text to parse the
time string.

-----Original Message-----
From: Wojciech Ciesielski [mailto:[EMAIL PROTECTED] 
Sent: 19 September 2005 15:57
To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
Subject: RE: a little bit OT: Calendar misbehaviour

> 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]
 
E-Mail Disclaimer 
 
Aus Rechts- und Sicherheitsgruenden ist die in dieser E-Mail gegebene 
Information nicht rechtsverbindlich. Eine rechtsverbindliche Bestaetigung 
reichen wir Ihnen gerne auf Anforderung in schriftlicher Form nach. 
Beachten Sie bitte, dass jede Form der unautorisierten Nutzung, 
Veroeffentlichung, Vervielfaeltigung oder Weitergabe des Inhalts dieser 
E-Mail nicht gestattet ist. Diese Nachricht ist ausschliesslich fuer 
den bezeichneten Adressaten oder dessen Vertreter bestimmt. Sollten Sie 
nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein, 
so bitten wir Sie, sich mit dem Absender der E-Mail in Verbindung zu setzen.


For legal and security reasons the information provided in this e-mail is not 
legally binding. Upon request we would be pleased to provide you with a legally 
binding confirmation in written form. Any form of unauthorised use, 
publication, 
reproduction, copying or disclosure of the content of this e-mail is not 
permitted. 
This message is exclusively for the person addressed or their representative. 
If you are not the intended recipient of this message and its contents, please 
notify the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to