Article View: borland.public.jbuilder.java.swing
Article #10296Re: System.currentTimeMillis problem
From: Johan Forsberg
Date: Tue, 26 Oct 1999 00:00
Date: Tue, 26 Oct 1999 00:00
26 lines
1553 bytes
1553 bytes
Ernesto Basc�n Pantoja <bascone@estudiantes.ucbcba.edu.bo> skrev i
diskussionsgruppsmeddelandet:380603D1.F4B4B480@estudiantes.ucbcba.edu.bo...
> I have a funny problem with System.currentTimeMillis(). I have the
following code to
> get the system current time:
> public static String getStringTime()
>
> long timemillis = System.currentTimeMillis();
> Calendar cal = new GregorianCalendar();
> cal.setTime(new Date(timemillis));
> return cal.get(Calendar.HOUR_OF_DAY) + ":" +
> cal.get(Calendar.MINUTE) + ":" +
> cal.get(Calendar.SECOND);
> }
> Well, when I call this method in Win95 or Win98, the returned value is ONE
hour more
> than the current system time. I tested it in WinNT and it works fine.
Strange... It works for me (Win98). I just wanted to mention that a simpler
way of getting
the current time as a String is
SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss");
return sdf.format(new Date());
Technical Details
Message-ID:
<7v4bin$mtu2@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<380603D1.F4B4B480@estudiantes.ucbcba.edu.bo>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,a1ca636bb832f79c X-Google-Attributes: gid111d45,public From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se> Subject: Re: System.currentTimeMillis problem Date: 1999/10/26 Message-ID: <7v4bin$mtu2@forums.borland.com> X-Deja-AN: 540765612 References: <380603D1.F4B4B480@estudiantes.ucbcba.edu.bo> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.swing