Here you can find the source of isToday(String sdate)
public static boolean isToday(String sdate)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static ThreadLocal<SimpleDateFormat> DATE_FORMATER = new ThreadLocal<SimpleDateFormat>() { @Override//from w w w . ja v a 2 s. c o m protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }; private final static ThreadLocal<SimpleDateFormat> DATE_FORMATER_2 = new ThreadLocal<SimpleDateFormat>() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } }; public static boolean isToday(String sdate) { boolean b = false; Date time = toDate(sdate); Date today = new Date(); if (time != null) { String nowDate = DATE_FORMATER_2.get().format(today); String timeDate = DATE_FORMATER_2.get().format(time); if (nowDate.equals(timeDate)) { b = true; } } return b; } public static Date toDate(String sdate) { return toDate(sdate, DATE_FORMATER.get()); } public static Date toDate(String sdate, SimpleDateFormat dateFormater) { try { return dateFormater.parse(sdate); } catch (ParseException e) { return null; } } }