Date Picker in Android – Month 0?

So I’m working on a new Android app and was having a small problem with the Date Picker widget. My datepicker.getMonth() kept returning incorrectly. What was the problem? The month is zero-based.

“year — The initial year.
monthOfYear — The initial month starting from zero.
dayOfMonth — The initial day of the month.”

So for my application, I have to call getMonth()+1 every time. I thought this was odd, but I found a comment on Stack Overflow that pointed out that if you had an array of months, you’d want the array value to match up with the month. Interesting

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>