Here you can find the source of getNowTime()
public static String getNowTime()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//from w w w . j a v a2s . c o m * return current time value in format: yyyy-MM-dd HH:mm:ss:sss * * @return String value */ public static String getNowTime() { return dateToStringWithPattern(new Date(), "yyyy-MM-dd HH:mm:ss:sss"); } /** * return time value of specified date * * @param date the specified date to convert * @param pattern time format * @return String value */ public static String dateToStringWithPattern(Date date, String pattern) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(date); } catch (Exception e) { return ""; } } }