Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

Windows 7 and Java getTime function


(!)

esokol's Avatar
esokol esokol is offline
Computer Specs
Member with 2 posts.
THREAD STARTER
 
Join Date: Jul 2012
Experience: Advanced
17-Jul-2012, 04:17 PM #1
Post Windows 7 and Java getTime function
I am running on Windows 7 Professional, Service Pack 1, 64 bit. I am also using Java 1.4.02_08 (old but serviceable for our purposes).

When I run my code on XP, the variable todayTime using the Java getTime() function returns the correct local time - namely the time which shows on my computer clock which is GMT-06 (Central time USA).

I recently upgraded to Windows 7 and running the same code, the variable todayTime using the Java getTime() function returns GMT time not the local time shown on the computer. I have looked at the computer clock during restart and the BIOS shows the correct local time.

My question - what do I need to do to get the Java function to work with Windows 7?

Here's the code snippet:
Calendar today = Calendar.getInstance();
SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy");
String defaultDate = dateformat.format(today.getTime());
SimpleDateFormat timeformat = new SimpleDateFormat("hh:mm a");
java.util.Date todayTime = today.getTime();
String defaultTime = timeformat.format(todayTime);

Thanks in advance.
Popa Mintin's Avatar
Popa Mintin Popa Mintin is offline Popa Mintin has a Profile Picture
Computer Specs
Member with 25 posts.
 
Join Date: Jun 2008
Location: North Lincolnshire. England
Experience: Intermediate
09-Aug-2012, 06:29 AM #2
I recall having a similar problem some while back and it turned out to be that I'd not set the correct options in: -
Start> Control Panel> Region and Language.
Once I corrected that, all my date n time functions worked as expected.

Popa.
esokol's Avatar
esokol esokol is offline
Computer Specs
Member with 2 posts.
THREAD STARTER
 
Join Date: Jul 2012
Experience: Advanced
09-Aug-2012, 07:51 AM #3
My regional setting were correct. Thanks for the suggestion.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2