T
Tim Slattery
I need to extract the month from a Date object as an integer, where
month would range from 1 (for January) to 12 (for December). In the
documentation for the Data object, I see a deprecated getMonth().
Instead of getMonth, we're supposed to create a Calendar object and
use the Calendar.get(Calendar.MONTH) method.
But that method returns one of the Calendar values JANUARY,
FEBRUARY....DECEMBER. So, to get my integer I have to make a long
switch statement to figure out which of these values was returned. I
can't find any discussion of what the month values actually are.
Is there a way to shortcut this rigamarole? It seems that what should
take one line of code is taking about 40 instead.
month would range from 1 (for January) to 12 (for December). In the
documentation for the Data object, I see a deprecated getMonth().
Instead of getMonth, we're supposed to create a Calendar object and
use the Calendar.get(Calendar.MONTH) method.
But that method returns one of the Calendar values JANUARY,
FEBRUARY....DECEMBER. So, to get my integer I have to make a long
switch statement to figure out which of these values was returned. I
can't find any discussion of what the month values actually are.
Is there a way to shortcut this rigamarole? It seems that what should
take one line of code is taking about 40 instead.