Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert Long datatype into a DateTime of a Particular  TimeZone

Posted on 2008-11-14
7
Medium Priority
?
353 Views
Last Modified: 2013-11-13
Hello I would like to convert Long datatype into datatime of TimeZone that user selects example :

TimeZone selected : GMT-1200
long Num = 1226505300156

how can i get it in DateTime ?

Appreciate help
0
Comment
Question by:Siddhardh
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 22961849
Just set the TimeZone on the DateFormat you use to format/parse it
0
 

Author Comment

by:Siddhardh
ID: 22961894
Can you solve this please

TimeZone selected : GMT-1200
long Num = 1226505300156

long time = scan.getTimeinLong();

DateFormat formatter = new SimpleDateFormat("MM-DD-YYYY:hh:mm:ss", Locale.US); /// do i need Locale.US ????
TimeZone tz = TimeZone.getTimeZone(q.getTimezone()); // ex:GMT-1200
formatter.setTimeZone(tz);
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 22961972
Yes:
formatter.setTimeZone(TimeZone.getTimeZone("GMT-12"));

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Siddhardh
ID: 22962037
ok what you did is one step less from waht i did thank you though

i need the long to be converted into that TimeZone
0
 

Author Comment

by:Siddhardh
ID: 22962046
long time = scanTask.getPickupConfig();
                                     
                                    DateFormat formatter = new SimpleDateFormat("MM-DD-YYYY:hh:mm:ss", Locale.US);
                                  formatter.setTimeZone(TimeZone.getTimeZone(gdsQueue.getTimezone()));
                                                                formatter.format(time);
0
 

Author Comment

by:Siddhardh
ID: 22962050
Hopefully it will work :P
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 22962140
>>/// do i need Locale.US ????

No. Not unless you need it for some reason
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question