Here you can find the source of now()
public static String now()
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/* ww w. java2 s . c o m*/ * @return current time with respect to the format yyyy-MM-dd-HH-MM-ss */ public static String now() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); Date date = new Date(); return dateFormat.format(date); } }