Android Time Compare isTimeAfter(String webTime, String localTime)

Here you can find the source of isTimeAfter(String webTime, String localTime)

Description

is Time After

Declaration

@SuppressLint("SimpleDateFormat")
    public static int isTimeAfter(String webTime, String localTime) 

Method Source Code

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import android.annotation.SuppressLint;

public class Main {
    @SuppressLint("SimpleDateFormat")
    public static int isTimeAfter(String webTime, String localTime) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        // Log.i("WEB", "isTimeAfter: time1 " + theTime + " time2 " + theTime2);

        Date serverTime = null;/*www .j  a v a2s.c  om*/
        Date deviceTime = null;
        try {
            serverTime = sdf.parse(webTime);
            deviceTime = sdf.parse(localTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        // n < 0 before
        // n > 0 after
        // n == 0 equal
        return serverTime.compareTo(deviceTime);
    }
}

Related

  1. isEarilerDate(Time t1, Time t2)
  2. isPastDateTime(DateTime target)
  3. isSameDate(Time t1, Time t2)
  4. isSameLocalTime(Calendar cal1, Calendar cal2)
  5. isSameMonth(Time t1, Time t2)
  6. isOnRange(String fromTime, String toTime)
  7. javaToDosTime(long time)
  8. timeEnd(String tag, long threshold)