java.text.ParseException: Unparseable date: 2010-12-10 17:18:3600
i'm getting this exception when i try to parse a date that i get from a SQL database, the date is a datetime on the sql and i recive it as a String with JSON, and seeing the excepcion i think that the string i recived is like this:2010-12-10 17:18:3600
this is the exception i get:
java.text.ParseException: Unparseable date: 2010-12-10 17:18:3600
i use the next code to parse the date (i get it from google) but it gets the exception
How can i modify this code to get the parse working???? please guive me the answer with code, date parsing and using of simpledateformat it's very hard for me
public void setPositiontime(String positiondate)
{
SimpleDateFormat FORMATTER = new SimpleDateFormat("d MMM yyyy HH:mm");
// pad the date if necessary
while (!positiondate.endsWith("00")){
positiondate += "0";
}
开发者_JAVA百科 try {
this.positiondate = FORMATTER.parse(positiondate.trim());
} catch (ParseException e) {
throw new RuntimeException(e);
}
i get the error on this line: this.positiondate = FORMATTER.parse(positiondate.trim());
Try this SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:SSSS"); It is simply a representation of what each digit in the format means so its: Years-months-date hour:min:milli
精彩评论