This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
timestamp in jdk1.4 and jdk1.7 (Gives two different result)
thilsen kumar
Greenhorn
Joined: Jul 10, 2007
Posts: 13
posted
0
Hi all,
I want clarify one thing.
I installed j2sdk1.4.2_03 and jdk1.7 in my system.
when i run the following program it gives two different result in two version of java my system timezone setting is -08:00 (Pacific US & Canada )
class DB {
public static void main (String args []) throws SQLException {
try {
DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss Z");
Timestamp today = new Timestamp(df.parse("20081027023050 -0800").getTime());
System.out.println("Today = " + df.format(today));
}catch (ParseException e)
{ e.printStackTrace(); }
}
}
when i run this with jdk1.4... it gives 20081027023050 -0800
when i run this with jdk1.7 it gives 20081027033050 -0700
Can anybody clarify this?
Thanks & Regards,
thilsen
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
Please read the important administrative private message I just sent you.
thilsen kumar
Greenhorn
Joined: Jul 10, 2007
Posts: 13
posted
0
Campbell Ritchie wrote:Please read the important administrative private message I just sent you.
ok
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
Thank you.
Welcome to JavaRanch
It is worthwhile checking whether there have been any changes to the rules about daylight saving time in the USA between 2001 when J2SE1.4 came out and 2006 when Java6 came out. That might explain the difference. Apart from that, I am afraid, don't know.
By the way, what's jdk1.7? Java7 hasn't been issued yet. Is it a version of gcj? I seem to remember my Fedora compiler is capable of saying it's 1.7.
Amit Singla
Greenhorn
Joined: Jun 20, 2008
Posts: 7
posted
0
If you see, both the times are same the only difference is the default value of timezone.
Please see this... http://java.sun.com/javase/timezones/.. java guys talk about this thing. I think 2007 onwards there are standard days when Daylight saving will be done so java compute the time zone (with daylight saving) based on these rules. In your programme, if yoy change the month to 12 (from 10)... you will start seeing time in -8:00 hrs.
thilsen kumar
Greenhorn
Joined: Jul 10, 2007
Posts: 13
posted
0
Thank you
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
4
posted
0
You're welcome
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: timestamp in jdk1.4 and jdk1.7 (Gives two different result)