Below code give current date in String.
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class CurrentDate {
public CurrentDate() {
super();
}
public static void main(String[] args) {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
}
}
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class CurrentDate {
public CurrentDate() {
super();
}
public static void main(String[] args) {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
}
}
No comments:
Post a Comment