i am try to parse string to date it works normally well but when i am use internationalization with &locate=fr then it will thrown java.lang.IllegalArgumentException.
hear is the peace of code i want to get date from string.
public static Date toDate(String date){
DateTimeFormat format = DateTimeFormat.getFormat("MM/dd/yy h:mm:s a");
return format.parseStrict(date);
}
and i am try to convert “02/02/2012 10:10:25 AM”.
please help me.
Try using parse() instead of parseStrict(). If you use
parse()dates are parsed leniently, so invalid dates will be wrapped around as needed. And withparseStrict()dates are parsed strictly, so invalid dates will result in anIllegalArgumentException. See you are using different format for your date.02/02/2012which corresponds toMM/dd/yyyynot toMM/dd/yy