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 java/18083] New: Calendar returns incorrect values for DAY_OF_YEAR and DAY_OF_WEEK after calling add().


Calendar returns incorrect values for DAY_OF_YEAR and DAY_OF_WEEK after 
calling add().

Here is an example code to test it:

import java.util.Calendar;

public class CalendarTest {
	public static void main( String [] args ) {
		boolean fail = false;
		Calendar c = Calendar.getInstance();

		c.set( 2004, 0, 1 );
		fail |= print( c, 1, 5 );

		c.add( Calendar.MONTH, 1 );
		fail |= print( c, 32, 1 );

		c.add( Calendar.MONTH, 1 );
		fail |= print( c, 61, 2 );

		c.add( Calendar.MONTH, 1 );
		fail |= print( c, 92, 5 );

		System.exit( fail ? 1 : 0 );

	}
	static boolean print( Calendar c, int doy, int dow ) {
		int y = c.get( Calendar.YEAR ), 
		    m = c.get( Calendar.MONTH ), 
		    d = c.get( Calendar.DAY_OF_MONTH ), 
		    actdoy = c.get( Calendar.DAY_OF_YEAR ), 
		    actdow = c.get( Calendar.DAY_OF_WEEK );

		if( actdoy != doy || actdow != dow ) {
			System.out.println( "FAIL: y="+y+", m="+m+", d="+d+", 
doy="+doy+", actdoy="+actdoy+", dow="+dow+", actdow="+actdow );
			return true;
		} else {
			System.out.println( "PASS: y="+y+", m="+m+", d="+d+", 
doy="+doy+", dow="+dow);
			return false;
		}
	}
}

-- 
           Summary: Calendar returns incorrect values for DAY_OF_YEAR and
                    DAY_OF_WEEK after calling add().
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        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=18083


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