Here you can find the source of getNowTime(String format, Locale loc)
public static String getNowTime(String format, Locale loc)
//package com.java2s; //License from project: Apache License import java.util.Date; import java.util.Locale; public class Main { public static String getNowTime(String format, Locale loc) { if (format == null) { format = "yyyy-MM-dd HH:mm:ss"; }//w ww .j av a2s . c om if (loc == null) return new java.text.SimpleDateFormat(format).format(java.util.Calendar.getInstance().getTime()); return new java.text.SimpleDateFormat(format, loc).format(java.util.Calendar.getInstance().getTime()); } public static String getNowTime(String format) { return getNowTime(format, null); } public static String getNowTime() { return getNowTime(null); } public static Long getTime(int length, Date date) { String time = String.valueOf(date.getTime()).substring(0, length); return Long.parseLong(time); } }