Here you can find the source of getNow()
public static String getNow()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getNow() { return getNow("yyyy-MM-dd"); }//from ww w . j a v a 2s . co m public static String getNow(String pattern) { Calendar now = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(now.getTime()); } }