I am seeing a string as Wed Apr 27 00:00:00 GMT-700 1988 and to convert it to date I did
Date dateOfBirth = new Date(bean.getUserProfileBean().getDateOfBirth());
This fails and I am not sure why. Any idea if it is specific to GAE?
I am seeing a string as Wed Apr 27 00:00:00 GMT-700 1988 and to convert it to date I did
Date dateOfBirth = new Date(bean.getUserProfileBean().getDateOfBirth());
This fails and I am not sure why. Any idea if it is specific to GAE?
The date Wed Apr 27 00:00:00 GMT-700 1988 is not in a format that Java can parse out of the box. Specifically, the timezone GMT-700 part is not parsable by any library that I know of.
This format is not any of the standard timezone formats: general timezone, RFC822 or ISO8601.
You will need to write your own parser for that.
Date has empty constructor or Date(long)
If you want to get date from String, you need to use SimpleDateFormat
Try:
stirng strDate = bean.getUserProfileBean().getDateOfBirth();
Date date = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy",
Locale.ENGLISH).parse(strDate );
See this answer
Alternatively you can try to use the DateTimeFormatter of Joda-Time, although you may encounter problems with the 'z' for timezone names whih is conventional:
stirng strDate = bean.getUserProfileBean().getDateOfBirth();
DateTimeFormatter dtf = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss z yyyy");
dtf.parseDateTime(strDate);