SimplicityApks / ReminderDatePicker

A Google Keep-like Date and Time Picker for reminders
Apache License 2.0
74 stars 26 forks source link

Getting Year value when user selects "Pick a date..." option #21

Closed shashi02 closed 9 years ago

shashi02 commented 9 years ago

HI. I am getting trouble in capturing the selected year in the DateSpinner that i have used in my code. When ever i select a date using "Pick a date..." option and set the date using below code:

findViewById(R.id.date_spinner).setSelectedDate(Calender.getTimeInMillis());

and the above code gives me date like 4 May, 5 Apr etc.

I would like to have it this way 4 May, 2015. Is there some possibility for that?

SimplicityApks commented 9 years ago

The default behaviour is that the Spinner will show the year value only when it's not the current year, which makes sense in most use-cases. What you're trying to achieve is entirely possible though, you'd only need to call setDateFormat() with for instance a new SimpleDateFormat("d MMM, yyyy") first in your onCreate() or so. Just be aware that different languages use different date formats, so you might want to get a default date pattern string for the current locale to modify.

shashi02 commented 9 years ago

It's working exactly as per my requirement. Thanks a lot :)