Write a java program to current Date and Time
import java.util.Date; //date class
import java.text.SimpleDateFormat; //SimpleDateFormat class
import java.text.Format; //Format class
public class Date1 {
public static void main(String[] args) {
Date na = new Date();
System.out.println(na);
String pattern="hh";
String pattern2="MM";
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
sdf.format(na);
System.out.println(sdf.format(na));
SimpleDateFormat sdf1=new SimpleDateFormat(pattern2);
sdf1.format(na);
System.out.println(sdf1.format(na));
}
}
0 comments:
Post a Comment