compare specified timestamp with current timestamp - Android java.util

Android examples for java.util:Calendar

Description

compare specified timestamp with current timestamp

Demo Code


//package com.java2s;

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

import java.util.Locale;

public class Main {
    /**/*from  w  w  w  .j  a v a  2 s .c o  m*/
     * compare specified timestamp with current timestamp
     */
    public static boolean compareTimestamp(long timestamp) {
        return Long.parseLong(getSimpleTimestamp()) > timestamp;
    }

    public static String getSimpleTimestamp() {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMDD",
                Locale.getDefault());
        return format.format(Calendar.getInstance().getTime());
    }
}

Related Tutorials