Here you can find the source of now(String formatStr)
public static String now(String formatStr)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String now(String formatStr) { Date date = new Date(); DateFormat format = new SimpleDateFormat(formatStr); return format.format(date); }//w w w .j a va2s .co m }