Hi Federico, try this code:
Date data = new Date();
Calendar now = Calendar.getInstance();
int hours = data.getHours();
int min = data.getMinutes();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH)+1;
int day = now.get(Calendar.DAY_OF_MONTH);
String hours = hour+":"+min;
String date = year+"/"+month+"/"+day;
I use this and it works, so try it, ok?
Regards,
Bruno Patricio
Portugal
At 10:15 AM 3/23/00 +0100, you wrote:
>Hi all,
> I faced a problem with time displayed by a servlet
>running on my system
>The servlet gets and display date/time using the following
>code:
>................
> Calendar now = Calendar.getInstance();
> int month = now.get(Calendar.MONTH) +1;
>
> String date = now.get(Calendar.DATE) +
> "/" + month +
> "/" +
>now.get(Calendar.YEAR) +
> " " +
>now.get(Calendar.HOUR_OF_DAY)+
> ":" +
>now.get(Calendar.MINUTE)+
> ":" + now.get(Calendar.SECOND);
>.................
>The date time displayed is quite wrong (3.5 hours after the
>system time), example
>the servlet says
>23/3/2000 13:38:46
>while the system time (issuing the date command line) is:
>Thu Mar 23 10:08:49 MET 2000.
>System info: Unix-Alpha system - Apache+Jserv - JDK 1.1.7.
>Does any one help me?
>Thanks in advance
> federico
>
>------------------------------------------------------------
>------
>Federico Delpino Tel. 39-51-20-95722
>Osservatorio Astronomico di Bologna Fax. 39-51-20-95700
>via Ranzani,1 - 40126 Bologna, Italy e-mail:
>[EMAIL PROTECTED]
>
>
>Attachment Converted: "\\Alunosw\Users\1996\xikinho\Attachments\DelpinoF.vcf"
>
Bruno Patricio
Eng� Inform�tica e Sistemas
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html