Date Format(yyyy-MM-dd HH:mm:ss) in java
Date Format(yyyy-MM-dd HH:mm:ss) in java
============================================================
============================================================
public static String getCurrentTimeStamp(){
String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf =
new SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance(); // current date and time by system
System.out.println("Today is " + sdf.format(c1.getTime()));
return sdf.format(c1.getTime());
}
============================================================String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf =
new SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance(); // current date and time by system
System.out.println("Today is " + sdf.format(c1.getTime()));
return sdf.format(c1.getTime());
}
Comments
Post a Comment