• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Time related issues

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you retrieving the time?
 
Manikandan Parthasarathi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the value of the time 0 before or after you convert it?
 
Manikandan Parthasarathi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't get you...
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The given long converted into actual time is "08:37:00.863"

[ September 18, 2008: Message edited by: Rene Larsen ]
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic