Link to home
Start Free TrialLog in
Avatar of letsbedecent
letsbedecent

asked on

Date value

Hi all,

       I need to create a new date with a value of april 20th 2004. How do i do that....  new Date(int,int,int) is depricated, so how can i do this

Thank you
SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of letsbedecent
letsbedecent

ASKER

What all should be imported to get this working ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, change the 25 to 20, but I'm sure you get the idea!
imports are:

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
or just do:
import java.util.*;
Here's a working example:

--------------
package examples;

import java.util.*;

public class MyDate {
      
      public static void main(String[] args){
            Calendar mydate= new GregorianCalendar(2004, Calendar.APRIL, 20);
            Date date = mydate.getTime();
            System.out.println( "Date is " + date )      ;
      }
}
--------------