10-27-2011 06:31 PM
English locale the string date is "Oct 27, 2011 10:20 AM"
French locale the string date is "27 oct. 2011 10:20"
I need to get "2011-10-27 10:20 AM" from both strings. I've tried using httpdatparser and simpledateformat but contin to get a 1969 date. Any ideas?
10-27-2011 06:44 PM
sdf should be able to handle either, give us an example of your code.
10-27-2011 06:56 PM
Here is the code that produces the 1969 date...
String a = "Oct 21, 2011 10:30 AM";
Dialog.inform(StringToDate(a));
publicstatic String StringToDate(String dateToParse) {
Date formatter =
new Date(HttpDateParser.parse(dateToParse));
SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
formatter.setTime(formatter.getTime());
String strCustomDateTime = dateFormat.format(formatter);
return strCustomDateTime;
}
10-28-2011 03:35 AM
10-28-2011 09:00 AM
Thanks Simon. The string is coming directly from the OS based on language. I assume httpdateparser should understand all formats that come the OS based on local. My concern is that if my app is to be bilingual (en / fr) and I need a consistent date format regardless of English of French, how do I produce this consistent format (yyyy-MM-dd HH:mm:ss) when Eng displays a date one way and French another way?
10-28-2011 09:07 AM
10-28-2011 09:36 AM
10-28-2011 09:42 AM
10-28-2011 10:19 AM
I do store the date as a long (Long answerDateTime) then put that Long into a DateField.
DateField dfAnswerDateTime = new DateField("", answerDateTime.longValue(), DateField.DATE_TIME);
I then use dfAnswerDateTime.toString(); to get the answer date as a string. Only issue is that is is completely different format based on language. Is there a parameter I can use in the DateField to maintain an exact format regardless of language?
I appreciate your assistance. Thanks much.
10-28-2011 10:27 AM