Name: rmT116609 Date: 08/26/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
and:
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
A JSpinner created using a SpinnerDateModel on the Calendar.AM_PM field does not roll properly. It will roll from AM to PM but not vice-versa.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the sample application included with this report.
2. Attempt to change the value of the spinner using the up or down button.
3. The spinner's value will change from AM to PM, but not vice versa. If you run the example in the afternoon, the field will not change.
EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected the spinner to change from PM to AM using the up or down buttons; it did not.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.util.Calendar;
import java.util.Date;
/**
* The JSpinner will change from AM to PM but not vice-versa.
*/
public class AmPmBug {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(600, 400);
JPanel spinnerPanel = new JPanel(new FlowLayout());
SpinnerDateModel model = new SpinnerDateModel(new Date(),
null, null, Calendar.AM_PM);
JSpinner spinner = new JSpinner(model);
JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner, "a");
spinner.setEditor(editor);
spinnerPanel.add(spinner);
f.getContentPane().add(spinnerPanel);
f.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
I've tried adding listeners to manually change the value, with no luck. The best work-around I can find is using a SpinnerListModel with new DateFormatSymbols().getAmPmStrings () and synchronizing with the Calendar. This seems to require that calendar.roll(Calendar.HOUR_OF_DAY, 12) be
used.
(Review ID: 163349)
======================================================================