| Author |
Time related issues
|
Manikandan Parthasarathi
Greenhorn
Joined: Jul 29, 2008
Posts: 16
|
|
Hi I am sending a message to jms.queue. I am reteriving the time from the server. But its not the actual time. when ever i restart it shows oo.oo.oo i want the time to be actual system time i am using EJB3.0 and JBoss 4.2.2 how i can set the regional time?
|
Regards
Manikandan
SCJP 5 , SCWCD 5
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
|
How are you retrieving the time?
|
Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
|
 |
Manikandan Parthasarathi
Greenhorn
Joined: Jul 29, 2008
Posts: 16
|
|
|
i am getting the time by this msg.getJMSTimestamp(). It returns a long which is a milliseconds. i conver that milliseconds into actual time.
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
|
Is the value of the time 0 before or after you convert it?
|
 |
Manikandan Parthasarathi
Greenhorn
Joined: Jul 29, 2008
Posts: 16
|
|
|
I didn't get you...
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
Sorry, I'll rephrase the question. 1.) What is the value after you call msg.getJMSTimestamp() 2.) What is the value after you convert that into actual time?
|
 |
Manikandan Parthasarathi
Greenhorn
Joined: Jul 29, 2008
Posts: 16
|
|
i am getting the following value 1221719820863, and i am not getting the same value every time. i am using following code to convert it into time format public String convert(long time) { int milliseconds = (int) (time % 1000); int seconds = (int) ((time / 1000) % 60); int minutes = (int) ((time / 60000) % 60); int hours = (int) ((time / 3600000) % 24); String millisecondsStr = ((milliseconds < 10) ? "00" : ((milliseconds < 100) ? "0" : "")) + milliseconds; String secondsStr = ((seconds < 10) ? "0" : "") + seconds; String minutesStr = ((minutes < 10) ? "0" : "") + minutes; String hoursStr = ((hours < 10) ? "0" : "") + hours; return new String(hoursStr + ":" + minutesStr + ":" + secondsStr + "." + millisecondsStr); } but i want server time to be synchronized with the regional time
|
 |
Rene Larsen
Ranch Hand
Joined: Oct 12, 2001
Posts: 1179
|
|
The given long converted into actual time is "08:37:00.863" [ September 18, 2008: Message edited by: Rene Larsen ]
|
Regards, Rene Larsen
Dropbox Invite
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
|
I would work with Rene's suggested code (no need to write your own conversion when Java has the API to do it for you)! You can also then look at Calendar and Locale classes in order to get things in the correct timezone etc.
|
 |
 |
|
|
subject: Time related issues
|
|
|