- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- java currentTimeMillis() not OK when date changed ...
Operating System - Linux
1822034
Members
3384
Online
109639
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2005 02:04 AM
тАО10-24-2005 02:04 AM
java currentTimeMillis() not OK when date changed while programm running.
It seems that a java program running on HP-UX 11iv1 (rp4440, b2600) doesn't see the correct time using currentTimeMillis() if the date command was used to update current time while the program is running.
=> the main class hereafter gets the current time each 5 seconds and prints it to screen.
- On a XP PC, the date and time is correctly updated after I change it on the desktop while the program is running.
- On a HP-UX system, the date/time update is not seen !!
This looks like a bug ?
-----------------------------------
import java.util.*;
public class Test
{
public static void main(String[] args) {
Date date = new Date();
while(true) {
date.setTime(System.currentTimeMillis());
System.out.println(date);
try {
Thread.sleep(5000);
} catch (Exception e) {
System.err.println(e);
}
}
}
}
=> the main class hereafter gets the current time each 5 seconds and prints it to screen.
- On a XP PC, the date and time is correctly updated after I change it on the desktop while the program is running.
- On a HP-UX system, the date/time update is not seen !!
This looks like a bug ?
-----------------------------------
import java.util.*;
public class Test
{
public static void main(String[] args) {
Date date = new Date();
while(true) {
date.setTime(System.currentTimeMillis());
System.out.println(date);
try {
Thread.sleep(5000);
} catch (Exception e) {
System.err.println(e);
}
}
}
}
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2005 02:10 AM
тАО10-24-2005 02:10 AM
Re: java currentTimeMillis() not OK when date changed while programm running.
Here is my output from 11.11
# /opt/java1.4/bin/java Test
Mon Oct 24 10:09:12 EDT 2005
Mon Oct 24 10:09:17 EDT 2005
Mon Oct 24 10:09:22 EDT 2005
Mon Oct 24 10:09:27 EDT 2005
Mon Oct 24 10:09:32 EDT 2005
Mon Oct 24 10:09:37 EDT 2005
Mon Oct 24 10:09:42 EDT 2005
What version of java you are running ?
Also check# date
-Arun
# /opt/java1.4/bin/java Test
Mon Oct 24 10:09:12 EDT 2005
Mon Oct 24 10:09:17 EDT 2005
Mon Oct 24 10:09:22 EDT 2005
Mon Oct 24 10:09:27 EDT 2005
Mon Oct 24 10:09:32 EDT 2005
Mon Oct 24 10:09:37 EDT 2005
Mon Oct 24 10:09:42 EDT 2005
What version of java you are running ?
Also check# date
-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2005 02:54 AM
тАО10-24-2005 02:54 AM
Re: java currentTimeMillis() not OK when date changed while programm running.
I'm using Java 1.4.2-04.
I've got a similar output:
$ java Test
Mon Oct 24 16:41:26 CEST 2005
Mon Oct 24 16:41:31 CEST 2005
Mon Oct 24 16:41:36 CEST 2005
Mon Oct 24 16:41:41 CEST 2005
The problem is when date is changed in the system while this program runs, it is not seen in the program, unless I quit and re-run it, for example, I entered the command :
date -u 10241640
while it was running for display above (between 16:41:31 and 16:41:36), and we can see that the program continues updating 5 and 5 seconds from the initial time. We only get the correct time after stopping/restarting the programm.
On a XP system, I get a correct "live" update of system time in the running programm:
C:\Documents and Settings\Administrator>java Test
Mon Oct 24 16:47:18 GMT+07:00 2005
Mon Oct 24 16:47:23 GMT+07:00 2005
Mon Oct 24 16:47:28 GMT+07:00 2005
Mon Oct 24 16:47:33 GMT+07:00 2005
Mon Oct 24 16:46:36 GMT+07:00 2005
Mon Oct 24 16:46:41 GMT+07:00 2005
Mon Oct 24 16:46:46 GMT+07:00 2005
Mon Oct 24 16:47:54 GMT+07:00 2005
Mon Oct 24 16:47:59 GMT+07:00 2005
(date aketered twice at 16:47:35 1mn back and
after 16:46:46 a bit more than 1mn forth).
I've got a similar output:
$ java Test
Mon Oct 24 16:41:26 CEST 2005
Mon Oct 24 16:41:31 CEST 2005
Mon Oct 24 16:41:36 CEST 2005
Mon Oct 24 16:41:41 CEST 2005
The problem is when date is changed in the system while this program runs, it is not seen in the program, unless I quit and re-run it, for example, I entered the command :
date -u 10241640
while it was running for display above (between 16:41:31 and 16:41:36), and we can see that the program continues updating 5 and 5 seconds from the initial time. We only get the correct time after stopping/restarting the programm.
On a XP system, I get a correct "live" update of system time in the running programm:
C:\Documents and Settings\Administrator>java Test
Mon Oct 24 16:47:18 GMT+07:00 2005
Mon Oct 24 16:47:23 GMT+07:00 2005
Mon Oct 24 16:47:28 GMT+07:00 2005
Mon Oct 24 16:47:33 GMT+07:00 2005
Mon Oct 24 16:46:36 GMT+07:00 2005
Mon Oct 24 16:46:41 GMT+07:00 2005
Mon Oct 24 16:46:46 GMT+07:00 2005
Mon Oct 24 16:47:54 GMT+07:00 2005
Mon Oct 24 16:47:59 GMT+07:00 2005
(date aketered twice at 16:47:35 1mn back and
after 16:46:46 a bit more than 1mn forth).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2006 10:58 PM
тАО08-03-2006 10:58 PM
Re: java currentTimeMillis() not OK when date changed while programm running.
Just though I'd update this as I spent ages searching for a solution to this problem and there's no resolution in this thread...
Basically, it's a deliberate HP ploy done for performance reasons:
http://www.hp.com/products1/unix/java/java2/sdkrte14/infolibrary/sdk_rnotes_1.4.2.03.html#date_time
Basically, it's a deliberate HP ploy done for performance reasons:
http://www.hp.com/products1/unix/java/java2/sdkrte14/infolibrary/sdk_rnotes_1.4.2.03.html#date_time
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP