Two Laptop Bag
The moose likes Java in General and the fly likes  Calendar in Java 1.5 and 1.3 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark " Calendar in Java 1.5 and 1.3" Watch " Calendar in Java 1.5 and 1.3" New topic
Author

Calendar in Java 1.5 and 1.3

Aris Tan
Greenhorn

Joined: Aug 05, 2005
Posts: 13
Hi,

I have the following code:

import java.util.*;



public class cal {
public static void main(String[] args) {


Calendar c = new GregorianCalendar();

Calendar c2 = Calendar.getInstance();
c2.set(Calendar.DAY_OF_MONTH,1);
c.setFirstDayOfWeek(c2.get(Calendar.DAY_OF_WEEK));



c.set(Calendar.DAY_OF_WEEK, 1);
c.set(Calendar.WEEK_OF_MONTH, 3);

System.out.println(c.getTime());

}
}


when I ran it in java 1.5 I get the output:
Sun Aug 21 20:40:19 EDT 2005


in java 1.3.1, this is printed out:
Sun Aug 14 20:55:11 EDT 2005


any ideas why?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
I've simplified the code a bit as follows:


I'm getting the following results on OS X, with the added twist that if I uncomment the println statement above, the output of the second println changes! Looks like something fishy is happening in the 1.3.1 JVM.

Java 1.4.2
Sat Aug 06 09:12:35 CEST 2005
Sun Aug 21 09:12:35 CEST 2005

Java 1.3.1
Sat Aug 06 09:12:39 CEST 2005
Sun Aug 14 09:12:39 CEST 2005

Java 1.3.1 - activating the commented-out println statement
Sat Aug 06 09:13:28 CEST 2005
Sun Jul 31 09:13:28 CEST 2005
Sun Jul 10 09:13:28 CEST 2005


Android appsImageJ pluginsJava web charts
Aris Tan
Greenhorn

Joined: Aug 05, 2005
Posts: 13
It appears to be a bug

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4476551
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4409072
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calendar in Java 1.5 and 1.3
 
Similar Threads
how to find how many sundays comes in 2 Dates
Expressiveness using implicit conversions
Need Help on Time conversion.
Question regarding Calendar in Java
Calender class and its components