Here you can find the source of isToday(String sdate)
public static boolean isToday(String sdate)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { private final static SimpleDateFormat dateFormater = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.CHINA); private final static SimpleDateFormat dateFormater2 = new SimpleDateFormat( "yyyy-MM-dd", Locale.CHINA); public static boolean isToday(String sdate) { boolean b = false; Date time = toDate(sdate); Date today = new Date(); if (time != null) { String nowDate = dateFormater2.format(today); String timeDate = dateFormater2.format(time); if (nowDate.equals(timeDate)) { b = true;//from w ww.j a va2s. c o m } } return b; } public static Date toDate(String sdate) { try { return dateFormater.parse(sdate); } catch (ParseException e) { try { return dateFormater.parse(new Date(toLong(sdate) * 1000L) .toGMTString()); } catch (ParseException e1) { return null; } } } public static boolean equals(String str1, String str2) { return str1 == str2 || str1 != null && str1.equals(str2); } public static long toLong(String obj) { try { return Long.parseLong(obj); } catch (Exception e) { } return 0; } }