tl;dr
myResultSet // Using JDBC 4.2 or later.
.getObject ( … , LocalDate.class ) // Returns a `LocalDate` object.
.atStartOfDay ( ZoneId.of ( "America/Los_Angeles" ) ) // Let java.time determine the moment when the day begins on a particular date in a particular time zone.
.getMonth() // `java.time.Month` enum object.
.getDisplayName ( // Automatically localized.
TextStyle.FULL_STANDALONE ,
Locale.of ( "en" , "US" )
) // Returns a `String` object.
Avoid legacy date-time classes
Update for a decade later since Question posted…
Both java.sql.Timestamp and java.sql.Date are part of the terribly flawed legacy date-time classes that have been supplanted by the modern java.time classes built into Java 8+.
JDBC 4.2+ requires every JDBC driver support of the java.time types.
java.time
| Legacy |
Modern |
java.sql.Date |
java.time.LocalDate |
java.sql.Timestamp |
java.time.Instant (generally)
java.time.OffsetDateTime (in JDBC) |
java.util.GregorianCalendar |
java.time.ZonedDateTime |
From a DATE type field in standard SQL representing a year-month-date, use java.time.LocalDate directly. Objects of this class represent a year, month, and day without the context of a time zone or offset from UTC.
LocalDate localDate = myResultSet.getObject ( … , LocalDate.class ) ;
If you want the first moment of the day on that date, specify a time zone. For any given moment the time of day varies around the globe by time zone.
ZoneId z = ZoneId.of ( "America/Los_Angeles" ) ;
ZonedDateTime zdt = localDate.atStartOfDay ( z ) ;
If you want the month of that moment, interrogate for a java.time.Month enum object.
Month month = zdt.getMonth() ;
Oracle SYSDATE
However, the Oracle command SYSDATE returns a date and time of day without the context of a time zone or offset-from-UTC. In Java that maps to the class java.time.LocalDateTime.
LocalDateTime ldt = myResultSet.getObject ( … , LocalDateTime.class )
We can interrogate LocalDateTime for the month. But be aware that this implicitly relies upon the time zone used by the Oracle database server. Around the end/beginning of a month, the result here may be the month before or after the result you may expect.
java.sql.Datethat was 1 hour ahead (presumably when time zones don’t match), could it then also be an hour behind? Any number of hours behind or ahead?