JDK-4862638 : SpinnerDateModel doesn't roll the year field when adding weeks in the editor
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.4.1,1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-05-12
  • Updated: 2003-12-02
  • Resolved: 2003-12-02
Related Reports
Relates :  
Description

Name: jk109818			Date: 05/12/2003


FULL PRODUCT VERSION :
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

FULL OS VERSION :
Microsoft Windows 2000 [Versi��n 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
When I add a week in the JSpinner component and the week value is the last week of month in the calendar, the year field doesn��t roll to the next year. Sorry about my english ;) I speak spanish.
Best regards,
Maximiliano Palacios


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;

public class MyJSpinner {

	public static void main(String[] args) {
		JFrame.setDefaultLookAndFeelDecorated(true);
		JFrame frame = new JFrame("JSpinnerDemoBug");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JLabel emptyLabel = new JLabel("");
		emptyLabel.setPreferredSize(new Dimension(300, 120));
		frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
		SpinnerDateModel sdm = new SpinnerDateModel(new Date(), null, null, Calendar.MONTH);
		JSpinner js = new JSpinner(sdm);
		js.setEditor(new JSpinner.DateEditor(js, "w MM/yyyy"));
		frame.getContentPane().add(js);
		frame.pack();
		frame.setVisible(true);
	}
}
---------- END SOURCE ----------
(Review ID: 185641) 
======================================================================

Comments
EVALUATION Name: apR10133 Date: 05/14/2003 The problem is that java.text.SimpleDateFormatter incorrectly parse the date "1 12/2003" of format "w MM/yyyy" to the Dec 29,2002. The test case to show the bug in SimpleDateFormatter is listed below: --------------------- test.java ------------------------ import java.text.*; import java.util.*; public class test { public static void main(String[] args) { SimpleDateFormat format = new SimpleDateFormat("w MM/yyyy"); Date date = format.parse("1 12/2003", new ParsePosition(0)); System.out.println("Date 1 12/2003 (w MM/yyyy) is parsed to "+date); } } --------------------------------------------------------- ###@###.### ====================================================================== The 1st week in 2003 is from 2002-12-29 to 2003-1-4. Because no day of week is specified, it uses the first day of week (Sunday for the US locale) as the day of week. So it picks up 2002-12-29 (Sunday). Note that "12" (month) is not used to determine the date. See the Calendar class description. Also note that GregorianCalendar doesn't support week-based year numbering, which is required to designate a date in the ISO 8601-style year, week of year, day of week combination. See 4267450. ###@###.### 2003-12-02
2003-12-02