Java Now now(String dateFormat)

Here you can find the source of now(String dateFormat)

Description

now

License

Open Source License

Declaration

public static String now(String dateFormat) 

Method Source Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String now() {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("h:mm a");
        return sdf.format(cal.getTime());
    }/*from   w  w  w.  j  a va2 s . co m*/

    public static String now(String dateFormat) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        return sdf.format(cal.getTime());
    }
}

Related

  1. now()
  2. now()
  3. now(String dateFormat)
  4. now(String dateFormat)
  5. now(String dateFormat)
  6. now(String formatStr)
  7. now(String pattern)
  8. now(String s, Date date)
  9. now_TimeZone_BY()