Here you can find the source of now(String s, Date date)
public static String now(String s, Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String now(String s) { SimpleDateFormat simpledateformat = new SimpleDateFormat(s); Date date = new Date(); GregorianCalendar gregoriancalendar = new GregorianCalendar(); gregoriancalendar.setTime(date); Date date1 = gregoriancalendar.getTime(); String s1 = simpledateformat.format(date1); return s1; }//from w ww .j a va 2 s. c o m public static String now(String s, Date date) { SimpleDateFormat simpledateformat = new SimpleDateFormat(s); String s1 = simpledateformat.format(date); return s1; } public static String now() { return now("yyyy-MM-dd HH:mm:ss"); } }