I have this sql query and Java code:
select to_char(start_date, 'DD/MM/YYYY') AS start_date FROM table
LogServiceFactory.getInstance().logError("-------From the Db " + rs.getString("start_date"));
LogServiceFactory.getInstance().logError("-------Formatter " + DateTime.parse(rs.getString("start_date"), formatter));
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/YYYY");
object.setStart_date(DateTime.parse(rs.getString("start_date"), formatter));
Here’s what’s in my log file:
2012-08-16 17:48:26 – ——-From the Db 08/08/2012
2012-08-16 17:48:26 – ——-Formatter 2012-08-08T00:00:00.000-04:00
Why is it that the formatter is converting 08/08/2012 to 2012-08-08T00:00:00.000-04:00
My assumption was that the date would come back as 08/08/2012.
Am I not using the formatter correctly?
I think that
DateTime.parsereturns a newDateTimeobject. So you call the standardtoString()method, which returns a ISO 8601 formatted date pattern.You can use
.toString("dd/MM/yyyy")for your log message.