tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jann VanOver <>
Subject RE: Date problem with Tomcat/IIS
Date Wed, 18 Apr 2001 21:35:19 GMT
Yes!  When you say cal.HOUR_OF_DAY (etc.) you're accessing a CONSTANT in the
calendar object.  

What you want to use is the SimpleDateFormat class.  It will do all that you

Like this:

SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); 

then ...

retVal = df.format(dt);

and it's done!

btw: this is a Java problem and has nothing to do with Tomcat or IIS

-----Original Message-----
From: H.F.N. den Boer []
Sent: Wednesday, April 18, 2001 11:55 AM
To: Tomcat users group
Subject: Date problem with Tomcat/IIS

Made a class to do a number of usefull things.
One of them is to get the prefix string for a custom servlet-log.

In the generated string, the date is correct but the time is always the
Example of return value: 18-04-2001 11:12:13 

I'm working with;
Win2K server, build 5.00.2195
IIS 5.0, configured with ISAPI filter
Tomcat 3.2.1 running as NT service

Below the code of the servlet.

Any ideas ?


  public String getLogDateTime() {
    StringBuffer retVal = new StringBuffer("");
    Date dt = new Date();
    cal = Calendar.getInstance();

    retVal.append(getDateOnlyNumbers(dt));  // add date
    retVal.append(" ");
    retVal.append(cal.HOUR_OF_DAY);         // add hour
    retVal.append(cal.MINUTE);              // add minute
    retVal.append(cal.SECOND);              // add second
    retVal.append(" ");

    return retVal.toString();

View raw message