Here you can find the source of today()
public static String today()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String today() { return datetimeToStr(new Date()).substring(0, 8); }/*from w w w . j a va 2 s.c om*/ // =============================================================== public static String datetimeToStr(Date dtSource) { // 'yyyy-mm-dd hh:nn:ss' SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); return formatter.format(dtSource); } }