Hi community,
I have a problem with an application which makes use of a mysql database. I have a class which saves the fields of every record on the table. One of the columns is of type Datetime. Sometimes (!) I query this column and get results like with a timestamp, with a ".0" in the end. After some time on solving the problem I gave up and changed my code, so that it controls for that:
String date=result.getString("my_date");
if(date.endsWith(".0")){
this.myDate = StringUtils.sqlTimeStampFormat.parse(result.getString("my_date").replace(".0", ""));
System.out.println("item" + this.id + "date" + this.myDate);
}else{
this.myDate = StringUtils.sqlTimeStampFormat.parse(result.getString("my_date"));
}
But I still get the same exception:
Exception in thread "Thread-14" java.lang.NumberFormatException: multiple points
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at java.text.DigitList.getDouble(Unknown Source)
at java.text.DecimalFormat.parse(Unknown Source)
at java.text.SimpleDateFormat.subParse(Unknown Source)
at java.text.SimpleDateFormat.parse(Unknown Source)
at java.text.DateFormat.parse(Unknown Source)
at org.et.bean.NewsItem.<init>(NewsItem.java:74)
...
But when I inspect the part
StringUtils.sqlTimeStampFormat.parse(result.getString("my_date").replace(".0", ""))
during debugging, eclipse is showing me the right date for the string.
Does anybody have a pointer why this happens and how I could solve this problem?
All the best,
konrad