This from Ron Gagnon

 try {
    /*
    ** we specify Locale.US since months are in english
    **   we want to parse a TimeStamp
    */
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss", Locale.US);

    /*** fix timezone in the SimpleDateFormat**  this is a bug in JDK1.1*/
    sdf.setCalendar(Calendar.getInstance());

    /***  create a Date (no choice, parse returns a Date object) ****/
    Date d = sdf.parse("11-Sept-2001 09:39:35");
    System.out.println(d.toString());

    /*** create a GregorianCalendar from a Date object *****/
    GregorianCalendar gc = new GregorianCalendar();
   /*** now set GregorianCalendar object from the date ***/
    gc.setTime(d);
    System.out.println(gc.getTime().toString());
    }
   catch (Exception e)
   {
    e.printStackTrace();
    }

HTH,
Martin-
----- Original Message ----- From: "Holshausen, Ron" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Monday, September 19, 2005 7:21 AM
Subject: RE: a little bit OT: Calendar misbehaviour


Ok, then I assume the problem is that calendar.getTimeInMillis() returns
the timestamp in UTC, and you need it in your local timezone?

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

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

That's what I am doing:
> Java.sql.Timestamp toReturn;
> SimpleDateFormat dateFormatTime("HH:mm");
> Calendar cal = new GregorianCalendar();
> cal.setTime(dateFormatTime.parse(timeString));
> toReturn = new Timestamp(cal.getTimeInMillis());

The problem is that I need to get Timestamp object but I can't find a
way to
set it... Apart from manual calculation of timestamp value based on
Calendar.getField() ...

Wojtek



---------------------------------------------------------------------
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]


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

Reply via email to