Here you can find the source of formatNow()
public static String formatNow()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from ww w.j a va 2 s . co m*/ * Formats a Date into a date/time string. * now the time value to be formatted into a time string. * @return the formatted time string. */ public static String formatNow() { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HH:mm:ss"); return format.format(new Date()); } }