views:

30

answers:

2

I'm having this kind of String:

Wed Oct 27 00:00:00 EEST 2010

and I want to parse this into type Date.

I've tried with

DateTimeFormat fmt = DateTimeFormat.getFormat("EEE MMM dd HH:mm:ss zzzz yyyy");

but it doesn't work.

Need help in getting this fixed. Thanks.

A: 

Try using simple date format. Here is an example.. SimpleDateFormat java docs...

String dt = "Wed Oct 27 00:00:00 EEST 2010";
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy");
Date date = format.parse(dt);
System.out.println("date = " + date);
Teja Kantamneni
Don't forget that SimpleDateFormat is unsynchronized so the parsing must be done in a synchronized block.
The Elite Gentleman
A: 

Thanks guys,

I need to use DateTimeFormat because with SimpleDateFormat it doesn't work because I'm using GWT.

I'm running my project with GWT plugin from IntellijIdea and there I have this 2 errors if I'm using SimpleDateFormat:

[ERROR] Line 164: SimpleDateFormat cannot be resolved to a type
[ERROR] Line 167: ParseException cannot be resolved to a type
Paul