Ticket #4555 (closed defect: fixed)

Bug contains 2 commit(s) | SVN Diffs for #4555

 

Opened 4 years ago

Chinese calendar missing constructor call to setTimeInMillis()

Reported by: kbrown(at)us.ibm.com Assigned to: doug
Priority: critical Milestone: 3.4.2
Component: unknown Version: 3.2
Keywords: closed Cc:
Load: Xref:
Java Version: sunjdk1.4.x Operating System: win32
Project (C/J): ICU4J Weeks: 0
Review: srl

Description

The ICU Chinese calendar seems to be missing a call to setTimeInMillis() in

its constructor. All the other ICU calendars seem to have this, and unless I explicitly call setTimeInMillis( someInt ) after creating a

ChineseCalendar, rollingaddingsetting fields seems to yield incorrect timestamps when getting the milliseconds later.

// This version doesn"t seem to work correctly com.ibm.icu.util.ChineseCalendar chineseCalendar = new com.ibm.icu.util.ChineseCalendar(); chineseCalendar.set( Calendar.YEAR, 22 ); chineseCalendar.set( Calendar.MONTH, 0 ); chineseCalendar.set( Calendar.DATE, 19 ); chineseCalendar.add( Calendar.DATE, 1 );

// This yields -144684979200000, which turns into Fri Mar 05 00:00:00 PST 2616 milli = chineseCalendar.getTimeInMillis();

System.out.println("chineseCalendar.getTimeInMillis() = " + milli); System.out.println("chineseCalendar date = " + new Date(milli));

// This version works as expected com.ibm.icu.util.ChineseCalendar chineseCalendar = new com.ibm.icu.util.ChineseCalendar(); // Must forcibly set the time in milliseconds to something or the milliseconds

will not evaluate correctly later

chineseCalendar.setTimeInMillis( System.getTimeInMillis() ); chineseCalendar.set( Calendar.YEAR, 22 ); chineseCalendar.set( Calendar.MONTH, 0 ); chineseCalendar.set( Calendar.DATE, 19 ); chineseCalendar.add( Calendar.DATE, 1 );

// This yielded 1109626848245 in testing, which turns into Mon Feb 28 13:40:48

PST 2005,

// which was the expected date result (hours, minutes and seconds can be

ignored for my purposes)

milli = chineseCalendar.getTimeInMillis();

System.out.println("chineseCalendar.getTimeInMillis() = " + milli); System.out.println("chineseCalendar date = " + new Date(milli));

Attachments

Change History

12/31/69 17:19:18 changed by auditor

  • Wed Jun 15 12:17:01 2005 weiv changed notes2: assign: "" to "srl", target: "UNSCH" to "",
  • Wed Jun 15 12:17:01 2005 weiv moved from incoming to formatting
  • Wed Jun 15 13:42:16 2005 grhoten changed notes2: priority: "" to "medium", target: "UNSCH" to "3.4", weeks: "" to "0.05",
  • Tue Sep 27 14:12:18 2005 weiv changed notes2: (via expression '$PglTl3.5') target: "3.4" to "",
  • Thu Dec 15 21:55:39 2005 weiv changed notes2: priority: "medium" to "critical", target: "UNSCH" to "3.6",
  • Fri Dec 16 10:47:42 2005 dougfelt changed notes2: assign: "srl" to "doug", review: "" to "srl", target: "3.6" to "3.4.2",
  • Fri Dec 16 11:20:24 2005 srl changed notes2: xref: "" to "4978",
  • Mon Dec 19 11:02:50 2005 dougfelt changed notes2: xref: "4978" to "",
  • Mon Jan 23 11:12:50 2006 srl moved from formatting to fixed
  • Sun Oct 22 07:29:00 2006 grhoten moved from fixed to closed

Add/Change #4555 (Chinese calendar missing constructor call to setTimeInMillis())




Anti spam check: