Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6593610

JSpinner with DateEditor can't spin Date and Time Pattern 'k'

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_02"
      Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP ver 5.1 SP 2

      A DESCRIPTION OF THE PROBLEM :
      When specifying
      "dd.MM.yyyy kk:mm:ss:SS"
      as the Format for the DateEditor used by a JSpinner with SpinnerDateModel, you can't spin the 'kk'-Part of the String.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Define a JSpinner with SpinnerDateModel.
      Set the Editor up with a Format-Specification that includes a "Hour in day (1-24)" SimpleDateFormat (kk).
      Run the Application and try to spin the hour-Value.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All Values can be spun by shifting the Carret at the right position and clicking one of the spin Buttons. The right Value is highlighted.
      ACTUAL -
      The Hours-Value specified as "Hour in day (1-24)" kk can not be spun and is not highlighted.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;
      import java.util.Date;

      import javax.swing.JOptionPane;
      import javax.swing.JPanel;
      import javax.swing.JSpinner;
      import javax.swing.SpinnerDateModel;

      public class Test extends JPanel
      {
      private static JSpinner dateSpinner;
      private static final String FORMAT = "dd.MM.yyyy kk:mm:ss:SS";

      public static void main(String[] args) {

      dateSpinner = new JSpinner(new SpinnerDateModel(new Date(System.currentTimeMillis()), null, null, Calendar.YEAR));
      dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, Test.FORMAT));

      Test f = new Test();
      f.add(dateSpinner);
      JOptionPane.showConfirmDialog(null, f);

      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use 'HH' instead of 'kk' which is 'Hour in day (0-23)'.

            peterz Peter Zhelezniakov
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: