Here you can find the source of isBeforeHourTime(String compactTime, int hour)
public static boolean isBeforeHourTime(String compactTime, int hour)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; import android.util.Log; public class Main { private static final String TAG = "DateTimeUtil"; public static boolean isBeforeHourTime(String compactTime, int hour) { Log.d(TAG, "compateTime: " + compactTime); if (compactTime.trim().length() < 14) { /** Illegal format look as original time */ return true; }// www. j av a2 s. c o m String beforeTime = addHourTime(hour); Log.d(TAG, "beforeTime: " + beforeTime); if (compactTime.compareTo(beforeTime) < 0) { return true; } else { return false; } } public static String addHourTime(int hour) { GregorianCalendar gcalendar = new GregorianCalendar(); gcalendar.add(Calendar.HOUR, hour); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); return sdf.format(gcalendar.getTime()); } }