is After Silence Time - Android java.util

Android examples for java.util:Time

Description

is After Silence Time

Demo Code


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{
    public static boolean isAfterSilenceTime(String silenceTime) {
        Calendar now = Calendar.getInstance();

        now.setTime(new Date());

        LogUtil.debugLog("now Time:" + now.getTime());
        Calendar silence = Calendar.getInstance();

        SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd HH:mm");

        try {//www  .j a v  a2s  . co m
            silence.setTime(format.parse(silenceTime));
        } catch (ParseException e) {
            e.printStackTrace(); 
        }
        LogUtil.debugLog("silence Time:" + silence.getTime());
        LogUtil.debugLog("compare result:" + now.compareTo(silence));

        if (now.compareTo(silence) > 0) {
            return true;
        }

        return false;
    }
}

Related Tutorials