public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/18083] New: Calendar returns incorrect values for DAY_OF_YEAR and DAY_OF_WEEK after calling add().
@ 2004-10-20 15:52 mnefedov at rogers dot com
  2004-10-20 17:19 ` [Bug libgcj/18083] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mnefedov at rogers dot com @ 2004-10-20 15:52 UTC (permalink / raw)
  To: java-prs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-03-23 21:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 15:52 [Bug java/18083] New: Calendar returns incorrect values for DAY_OF_YEAR and DAY_OF_WEEK after calling add() mnefedov at rogers dot com
2004-10-20 17:19 ` [Bug libgcj/18083] " pinskia at gcc dot gnu dot org
2004-10-20 17:33 ` mnefedov at rogers dot com
2004-10-20 19:16 ` pinskia at gcc dot gnu dot org
2005-03-23 21:36 ` cvs-commit at gcc dot gnu dot org
2005-03-23 21:37 ` cvs-commit at gcc dot gnu dot org
2005-03-23 21:39 ` tromey at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).