Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private final static ThreadLocal<SimpleDateFormat> dateFormater2 = new ThreadLocal<SimpleDateFormat>() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } }; public static long getToday() { Calendar cal = Calendar.getInstance(); String curDate = dateFormater2.get().format(cal.getTime()); curDate = curDate.replace("-", ""); return Long.parseLong(curDate); } }