Convert Long datatype into a DateTime of a Particular TimeZone

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
SiddhardhAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Just set the TimeZone on the DateFormat you use to format/parse it
0
SiddhardhAuthor Commented:
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
CEHJCommented:
Yes:
formatter.setTimeZone(TimeZone.getTimeZone("GMT-12"));

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

SiddhardhAuthor Commented:
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
SiddhardhAuthor Commented:
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
SiddhardhAuthor Commented:
Hopefully it will work :P
0
CEHJCommented:
>>/// do i need Locale.US ????

No. Not unless you need it for some reason
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.