oracle sql:
select trunc( sysdate, 'Month') month
from dual
java:
java.sql.Date sqlDate = resultSet.getDate("month");
log.info(sqlDate);
DateTime dateTime = new DateTime(sqlDate.getTime());
log.info(dateTime);
dateTime = dateTime.withMillisOfDay(0);
log.info(dateTime);
output:
2012-01-01
2012-01-01T 01:00:00.000+07:00
2012-01-01T 00:00:00.000+07:00
where did the extra hour?
Use
LocalDate.fromDateFields(date)to interpret the SQL date as local (ignoring time-zone). You can then use methods onLocalDateto get aDateTimeif necessary (although if your object really is “just a date” thenLocalDateis the right object to use.