Here you can find the source of isDateNew(String YearMonthDayHourMinuteSeconds)
@SuppressLint("SimpleDateFormat") public static boolean isDateNew(String YearMonthDayHourMinuteSeconds)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import android.annotation.SuppressLint; public class Main { @SuppressLint("SimpleDateFormat") public static boolean isDateNew(String YearMonthDayHourMinuteSeconds) { boolean flag = false; int numOfDays = -14; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, numOfDays); Date fourteenDaysAgo = cal.getTime(); String expectedPattern = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern); Date date;/* w w w . j a va 2 s . c o m*/ try { date = formatter.parse(YearMonthDayHourMinuteSeconds); if (date.after(fourteenDaysAgo) || date.equals(fourteenDaysAgo)) { flag = true; } else { flag = false; } } catch (Exception e) { flag = false; } return flag; } }