3
JSpinner spinner = new JSpinner();
SpinnerDateModel spinner_model = new SpinnerDateModel();
spinner_model.setCalendarField(Calendar.MINUTE);
spinner.setModel(spinner_model);
spinner.setEditor(new JSpinner.DateEditor(spinner, "hh:mm a"));

I am getting the time with date 1 January 1970 GMT.

How to get the correct year and timezone from spinner?

I think we can use:

date = new JSpinner(new SpinnerDateModel(
    new Date(TimeHelper.today()), null, null, Calendar.DAY_OF_WEEK));

But, Date is deprecated.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • `Date` is deprecated, but `JSpinner` is old, and [according to the spinner tutorial at oracle](https://docs.oracle.com/javase/tutorial/uiswing/components/spinner.html), `Date` is still the correct thing to use. – azurefrog Feb 12 '17 at 06:51
  • Perhaps something like [this](http://stackoverflow.com/questions/230126/how-to-handle-calendar-timezones-using-java) can help – MadProgrammer Feb 12 '17 at 06:55

0 Answers0