PDA

View Full Version : How to convert String to Date



Suma
24 Jun 2009, 7:22 AM
Hi,
I want to convert String to Date without using DateFormat and SimpleDateFormat. Kindly help me how to do this.

micgala
24 Jun 2009, 7:39 AM
You can use Date Deprecated methods...
Calendar is not available on GWT.

Why can't you/don't you want to use DateFormat?

Suma
24 Jun 2009, 8:27 PM
I don't want to use DateFormat, so kindly tell me any other method with an example.

micgala
24 Jun 2009, 11:22 PM
As I said before, since you don't want to use DateFormat, you can then parse your String into day/month/year/hours/minutes

and then set a Date object using that (setDate, setMonth, setYear, setHour, setMinutes)
Those methods are deprecated, but they will work...

asad_naeem
17 May 2010, 12:19 AM
Java Solution:
http://www.roseindia.net/java/java-conversion/StringToTimeExample.shtml

GWT Solution:
String time1 = "05/10/2010"
com.google.gwt.i18n.client.DateTimeFormat dtf = com.google.gwt.i18n.client.DateTimeFormat
.getFormat("MM/dd/yyyy");

Date date1 = dtf.parseStrict(time1);

micgala
17 May 2010, 12:27 AM
http://www.roseindia.net/java/java-conversion/StringToTimeExample.shtml

Hi, that example is not valid in the Gwt world.

Gwt does not emulate no method in java.text

Regards,
Michel.

PS: I don't see a point on resurrecting a 1 year old message....