|
|
 |
| Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Java Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

January 4th, 2007, 01:40 AM
|
|
Authorized User
|
|
Join Date: Aug 2005
Location: , , .
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
problem with java.util.Date
i've a small problem in this program ... date, hours, minutes & seconds are displayed correct, but month & year are displayed incorrect ... could u plz solve this problem
import java.util.*;
class Test
{
public static void main(String args[])
{
Date date=new java.util.Date();
int dd,mm,yy,hh,mi,ss;
String rightNow=null;
dd=date.getDate();
mm=date.getMonth();
yy=date.getYear();
hh=date.getHours();
mi=date.getMinutes();
ss=date.getSeconds();
rightNow=dd+"/"+mm+"/"+yy+" "+hh+":"+mi+":"+ss;
System.out.println(rightNow);
}
}
i'll wait 4 a good reply
|

April 20th, 2007, 02:48 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi,
The Date class's getMonth() will give month starting from 0, i.e. 0 for Jan and so on. The getYear() method will give you the year starting from 1900 for 2007 it'll give 107.
Regards,
Rakesh
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |