Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2008

Tip: Looking for answers? Try searching our database.

Wrong time

Thread view: 
netzorro - 18 Feb 2008 03:39 GMT
Hi all, hope you can help me
I have a program for Windows and it always returns a wrong time.
The time I get is 3 hours less than the windows os time.
This is happening with my program but also log4j is having the same problem.
This is the code I use:

public String GetLogTime ()
   {
Calendar cal = Calendar.getInstance ( TimeZone.getDefault () );
String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat (
DATE_FORMAT );
sdf.setTimeZone ( TimeZone.getDefault () );
return sdf.format ( cal.getTime () );
   }

I cannot understand what's going on
Thanks

Diego
Roedy Green - 18 Feb 2008 06:08 GMT
On Mon, 18 Feb 2008 01:39:12 -0200, "netzorro"
<netzorro@bluebottle.com> wrote, quoted or indirectly quoted someone
who said :

>I have a program for Windows and it always returns a wrong time.
>The time I get is 3 hours less than the windows os time.

Then configure the timezone in the control panel.

http://mindprod.com/jgloss/setclock.html to get the UTC correct.
http://mindprod.com/jgloss/vista.html
http://mindprod.com/jgloss/time.html
http://mindprod.com/jgloss/timezone.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.