-
Bug
-
Resolution: Fixed
-
P2
-
5.0
-
b45
-
generic
-
generic
/*
* Running with jdk 1.4
* Timestamp Value # 1 : 1970-01-02 00:00:00.999999999
* Timestamp Value # 2 : 1970-01-02 00:00:00.001
* after method returns true
*
* Running with jdk 1.5
* Timestamp Value # 1 : 1970-01-02 00:00:00.999999999
* Timestamp Value # 2 : 1970-01-02 00:00:00.001
* after method does not return the expected Value Call to after is Failed!
*/
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
public class TimestampBug {
public static void main(String args[]) {
int valToGeneralize = 0;
Timestamp inTimeVal2 = null;
String sLongTstampVal = null;
String sNanosVal = null;
boolean booRetVal;
try {
// setup
TimeZone tz = null;
tz = TimeZone.getDefault();
boolean b1 = tz.useDaylightTime();
if(!b1) {
Calendar cal = Calendar.getInstance(tz);
valToGeneralize =
tz.getOffset(cal.get(Calendar.ERA),cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH),cal.get(Calendar.DAY_OF_WEEK),cal.get(Calendar.MILLISECOND));
}
else {
valToGeneralize = tz.getRawOffset();
}
// end setup
//DateTime_Str_Val1=1970-01-02 00:00:00.001
//DateTime_Long_Val1=86400001
//Ref_Nano_Val = 999999999
sLongTstampVal = "86400001";
long tstampVal1 = Long.parseLong(sLongTstampVal);
tstampVal1=tstampVal1-valToGeneralize;
sNanosVal = "999999999";
int nanosSet = Integer.parseInt(sNanosVal);
Timestamp inTimeVal1= new Timestamp(tstampVal1);
inTimeVal1.setNanos(nanosSet);
System.out.println("Timestamp Value # 1 : " + inTimeVal1);
inTimeVal2= new Timestamp(tstampVal1);
System.out.println("Timestamp Value # 2 : " + inTimeVal2);
booRetVal = inTimeVal1.after(inTimeVal2);
if(booRetVal)
System.out.println("after method returns " + booRetVal);
else {
System.out.println("after method does not return the expected Value
" + "Call to after is Failed!");
}
} catch(Exception e) {
e.printStackTrace();
System.out.println("Call to after is Failed!");
}
}
}
- relates to
-
JDK-4340146 Calendar.equals modifies state
-
- Resolved
-
-
JDK-5003586 Timestamp.getTime() includes milliseconds unlike JDK 1.3
-
- Closed
-