Here you can find the source of now(String dateFormat)
public static String now(String dateFormat)
//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()); } }