Date gmt = null ; try { gmt= formatter.parse(gmtS); System.out.println(gmt); // prints correct GMT date. }
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Err, are you aware that your code really isn't doing anything other than truncating the seconds and milliseconds from a timestamp?
Also, it is unclear to me what you are trying to do. What is your spec? You are given a java.util.Date as input. What is your output? Another Date? A String?
One thing to keep in mind is that java.util.Date objects are essentially timestamps -- just a long value. They have no notion of timezone associated with their state. Or you can thing of them as all being in UTC. In either case, "converting the time zone" of a Date object doesn't make sense. But then, I'm not clear on what you are trying to do. [ May 17, 2006: Message edited by: Jeff Albertson ]
There is no emoticon for what I am feeling!
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
posted
0
The code as I posted it takes a current Timestamp and stores it in GMT format.
I've tested it and it works fine.
I was just wondering if it could be shortened.
Thanks.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
I'm still confused. The input to your "function" is a date given by getTimestamp. What is the output? String gmtS or the output of System.out.println(gmt)? What is the purpose of the second date object?