This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcj/18087] New: Calendar's HOUR field gets adjusted when setting DAY_OF_MONTH field.


Calendar's HOUR field gets adjusted when setting DAY_OF_MONTH field -- it 
should not be adjusted.

Here is a sample code.

import java.util.Calendar;
import java.text.SimpleDateFormat;

public class CalendarTest2 {
	public static void main( String [] args ) {
		
		boolean fail = false;
		Calendar c = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat( "EEEEEEEEEEEEE, 
yyyy-MM-dd [DDD] HH:mm:ss.SSSS" );
		
		System.out.println( "Today: " + df.format( c.getTime() ) );

		c.set( 2004, 9, 1, 12, 0, 0 );
		c.set( Calendar.MILLISECOND, 0 );
		System.out.println( df.format( c.getTime() ) );
		
		c.set( Calendar.DAY_OF_MONTH, 2 );
		System.out.println( df.format( c.getTime() ) );		
		
		c.set( Calendar.DAY_OF_MONTH, 3 );
		System.out.println( df.format( c.getTime() ) );		
		
		
		c.set( Calendar.DAY_OF_MONTH, 4 );
		System.out.println( df.format( c.getTime() ) );	
	}
}

Here is the output with the errors:
1: Today: Wednesday, 2004-10-20 [294] 13:51:47.0592
2: Friday, 2004-10-01 [275] 13:00:00.0000
3: Saturday, 2004-10-02 [276] 13:00:00.0000
4: Sunday, 2004-10-03 [277] 12:00:00.0000
5: Monday, 2004-10-04 [278] 12:00:00.0000

Error #1: line 2:  hour was set to 12 not 13. What is interesting in this 
case -- c.get( Calendar.HOUR ) will give 12 back. SimpleDateFormat() report 13 
though.

Error #2: line 4: hour is 12 now.

-- 
           Summary: Calendar's HOUR field gets adjusted when setting
                    DAY_OF_MONTH field.
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mnefedov at rogers dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18087


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]