4 ms·
> months are given in 0-11 which is totally inconsistent with how people normally number months and how the rest of the API works That numbering is consistent
by trimbo 14y ago
> months are given in 0-11 which is totally inconsistent with how people normally number months and how the rest of the API works
That numbering is consistent with Java and the constants in the Android API.
http://docs.oracle.com/javase/1.4.2/docs/api/constant-values.html#java.util.Calendar.JANUARY http://docs.oracle.com/javase/1.4.2/docs/api/constant-values...
http://developer.android.com/reference/java/util/Calendar.html#JANUARY http://developer.android.com/reference/java/util/Calendar.ht...
- erydo 14y agoYou're right, and I didn't doubt that. I meant it's self-inconsistent with how days and years are handled, not necessarily inconsistent with other calendar APIs within Java and Android. Sorry I wasn't clear.
- solarexplorer 14y agoI guess the idea is to use the month as an array index to convert it into a string. You don't usually convert the day of month or the year into a string. Nontheless I agree that it's bad API design.
- pwg 14y agoThen declare the array with 13 slots, fill slots 1-12 with the appropriate strings, and don't use slot 0. Or better, put in an error check for being passed a zero. Suddenly, a 1-12 value for "month" is directly an index into an array to convert the number into a string...