Problem about Date

S

Sameer

Please watch the following code:
(Though the constructor Date(int year, int month, int date) was
deprecated)
Note that I am creating a date object for the date 1 July 2006.

import java.util.*;
import java.text.*;

//The date is represented as a Date object or
//as the milliseconds since January 1, 1970,00:00:00 GMT.
public class DateDemo1 {
public static void main(String args[]) throws ParseException {
Date date= new Date(2006,7,1);
System.out.println("String representation of current
date:"+date.toString());
}
}

The output is
String representation of current date:Wed Aug 01 00:00:00 IST 3906

Am I wrong? What may be the problem?
How to create Date instance for desired date?
 
A

Andrew Thompson

Sameer said:
Please watch the following code:
(Though the constructor Date(int year, int month, int date) was
deprecated)
Note that I am creating a date object for the date 1 July 2006. ....
The output is
String representation of current date:Wed Aug 01 00:00:00 IST 3906

Am I wrong?

Yes. Note the instructions in the documentation for the
"three ints" form of the constructor.
...What may be the problem?

Note also, that constructor is deprecated.
How to create Date instance for desired date?

Try reading the rest of that document.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top