0

I'm trying to display in the DatePickerDialog the next year, but I get 1900. What is the problem with this code?

.get(Calendar.YEAR + 1),
krsteeve
  • 1,794
  • 4
  • 19
  • 29
user2867831
  • 15
  • 2
  • 9
  • 1
    You have to use `get(Calendar.YEAR) + 1` your actual solution is broken.`get()` method takes one argument that determines which field from Calendar should be returned. – Simon Dorociak Nov 20 '13 at 20:56

2 Answers2

8

Try this:

.get(Calendar.YEAR) + 1,
Dodd10x
  • 3,344
  • 1
  • 18
  • 27
  • and if I wanted to get the default date in my TextView? nza.setText(fmtDateAndTime.format(dateAndTime.getTime())); – user2867831 Nov 20 '13 at 21:05
  • Please accept this answer if it solved your problem. I don't understand your follow on question. Please elaborate. – Dodd10x Nov 20 '13 at 21:14
  • how to set next year in my textview?? .setText(fmtDateAndTime.format(dateAndTime.getTime())); – user2867831 Nov 20 '13 at 21:19
  • Are you asking me if that code is correct? Did you try it? You will likely need to format that to a string using a Date Formatter. – Dodd10x Nov 20 '13 at 21:32
0

If you need a datepicker with only year (Year Calendar) , then please refer YearPicker
for more information. its an customized yearPicker

enter image description here

Agilanbu
  • 2,747
  • 2
  • 28
  • 33