IT Certificaions

Google Cloud Platform

Monday, July 11, 2011

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());
      }
============================================================