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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.GregorianCalenda r;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalenda
or just do:
import java.util.*;
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 ) ;
}
}
--------------
--------------
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 ) ;
}
}
--------------
ASKER