🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10310

Hi: System.currentTimeMillis problem

#10310
From: Ernesto Bascón Pantoja
Date: Thu, 14 Oct 1999 00:00
62 lines
2992 bytes
--------------829CFF73BD92C58CE43BE65E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi:

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.

Does someone know if it is a bug or a feature or am I doing something
wrong?

Thanx

Ernesto

--------------829CFF73BD92C58CE43BE65E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi:
<p>I have a funny problem with System.currentTimeMillis(). I have the following
code to get the system current time:
<p><tt>&nbsp; public static String getStringTime()</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; long timemillis = System.currentTimeMillis();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; Calendar cal = new GregorianCalendar();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; cal.setTime(new Date(timemillis));</tt><tt></tt>
<p><tt>&nbsp;&nbsp;&nbsp; return cal.get(Calendar.HOUR_OF_DAY)&nbsp; +
":" +</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cal.get(Calendar.MINUTE) + ":" +</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cal.get(Calendar.SECOND);</tt>
<br><tt>&nbsp; }</tt><tt></tt>
<p><font face="Arial,Helvetica">Well, when I call this method in Win95
or Win98, the returned value is ONE&nbsp; hour more than the current system
time. I tested it in WinNT and it works fine.</font><font face="Arial,Helvetica"></font>
<p><font face="Arial,Helvetica">Does someone know if it is a bug or a feature
or am I doing something wrong?</font><font face="Arial,Helvetica"></font>
<p><font face="Arial,Helvetica">Thanx</font><font face="Arial,Helvetica"></font>
<p><font face="Arial,Helvetica">Ernesto</font></html>

--------------829CFF73BD92C58CE43BE65E--
Technical Details
Message-ID: <380603D1.F4B4B480@estudiantes.ucbcba.edu.bo>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,a1ca636bb832f79c,start
X-Google-Attributes: gid111d45,public
From: Ernesto Bascón Pantoja  <bascone@estudiantes.ucbcba.edu.bo>
Subject: Hi: System.currentTimeMillis problem
Date: 1999/10/14
Message-ID: <380603D1.F4B4B480@estudiantes.ucbcba.edu.bo>
X-Deja-AN: 536714191
X-Accept-Language: en
Content-Type: multipart/alternative; boundary="------------829CFF73BD92C58CE43BE65E"
Organization: UCB
Mime-Version: 1.0
Reply-To: bascone@estudiantes.ucbcba.edu.bo
Newsgroups: borland.public.jbuilder.java.swing