-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.1.6, 1.1.8, 1.2.0, 1.2.2, 1.3.0, 1.3.1, 1.4.0, 1.4.1, 5.0, 5.0u8, 6
-
Fix Understood
-
generic, x86, sparc
-
generic, linux, solaris_8, solaris_9, windows_nt, windows_2000, windows_xp
Refer to tm_isdst spec of mktime() in the C library.
Name: krC82822 Date: 11/28/2000
28 Nov 2000, eval1127@eng -- 4248500 -> 4312621.
----------------
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I wrote a method that return the date for yesterday.
It has been working fine all month, but failed today.
I believe the roll() method has a bug.
The code to demonstrate this is here:
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateTest {
public static void main(String[] args) {
GregorianCalendar cal = new GregorianCalendar();
Date today = cal.getTime();
System.out.println("today: " + today);
cal.roll(Calendar.DATE,false);
Date yesterday = cal.getTime();
System.out.println("yesterday: " + yesterday);
}
}
When run, it produces this output:
today: Wed Nov 01 10:18:52 PST 2000
yesterday: Thu Nov 30 10:18:52 PST 2000
As you can see today is 1-Nov-2000, but yesterday
is 30-Nov-2000. It should be 31-Oct-2000.
So I changed the program to use the add() method,
instead of roll(). It looks like this
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateTest {
public static void main(String[] args) {
GregorianCalendar cal = new GregorianCalendar();
Date today = cal.getTime();
System.out.println("today: " + today);
cal.add(Calendar.DATE,-1);
Date yesterday = cal.getTime();
System.out.println("yesterday: " + yesterday);
}
}
This version produces the following result:
today: Wed Nov 01 10:23:07 PST 2000
yesterday: Tue Oct 31 10:23:07 PST 2000
Which is what I would expect.
(Review ID: 111696)
======================================================================
Name: yyT116575 Date: 07/17/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I have a column in Oralce database of date type. I have a data as '01-04-2001 02:00:00' of the format 'dd-mm-yyyy hh24:mi:ss'. When i read the program in java using 3rd party JDBC driver, i am getting the value of the date field as '01-04-2001 01:00:00'. Any time between 2.00AM to 2.59AM is shifted by one hour automatically. I suspect it is due to day light saving option enabled in my system. But even if i disable the daylight saving option, it is happening like this.How can fix this bug?
To explain this...
I have two objects date and time separately showing
the date and time for April 1st 2001 2 AM. I
concatanated these two strings and parsed in to a Date
object. Then the result shows again that it is 1st
April 2001 1 AM, the same old result!!!!.
java.sql.Time time = rs.getTime(1);
java.sql.Date date = rs.getDate(1);
System.out.println(time.toString()); //02:00:00
System.out.println(date.toString()); //2001-04-01
SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date date1 =
sdf.parse(date.toString().trim() + " " +
time.toString().trim());
System.out.println(new
Timestamp(date1.getTime()).toString()); //2001-04-01
01:00:00.0
(Review ID: 128200)
======================================================================
- duplicates
-
JDK-6482399 (cal) java.util.Calender add() and set() fail during DST to standard time transition
-
- Closed
-
-
JDK-4402769 Setting hour as 2 for Apr 1, 2001, CDT does not set it as 2 - gets set as 1
-
- Closed
-
-
JDK-4234799 DateFormat maps two DIFFERENT times into the same numeric
-
- Closed
-
-
JDK-4248500 roll methods for GregorianCalendar not working properly for October 31
-
- Closed
-
-
JDK-4284987 API: GregorianCalendar: undefined behaviour on daylight saving boundary
-
- Closed
-
-
JDK-4459694 Rolling times during a DST transition is incorrect
-
- Closed
-
-
JDK-4813743 Calendar.set() changes the daylight savings time marker
-
- Closed
-
-
JDK-6261305 (cal) Not consistent behaviour on Gregorian Calendar with dayligth saving
-
- Closed
-
-
JDK-6533596 (cal) Calendar obj. does not allow to set time to 1:30 AM EDT - 4th Nov 2007
-
- Closed
-
- relates to
-
JDK-4514831 GregorianCalendar, can't roll date from 10/28/2001 to 10/29/2001
-
- Resolved
-
-
JDK-4845901 SimpleDateFormat.parse(String) is an hour off for Australia EST TZ
-
- Resolved
-
-
JDK-4329879 (tz) Doc: TimeZone.getOffset is poorly documented
-
- Open
-
-
JDK-4845752 (tz) Wrong behavior JDK 1.3.1 in GregorianCalendar at DST boundary time
-
- Resolved
-
-
JDK-7022766 (cal) calendar.set works unexpectedly for DST
-
- Closed
-
-
JDK-4340168 (cal) RFE: Replace Calendar and GregorianCalendar
-
- Closed
-