Android Date Relative Format dateIsBetweenTwoDates(String begin, String end)

Here you can find the source of dateIsBetweenTwoDates(String begin, String end)

Description

date Is Between Two Dates

Declaration

public static boolean dateIsBetweenTwoDates(String begin, String end) 

Method Source Code

//package com.java2s;
import java.util.Calendar;

public class Main {
    public static boolean dateIsBetweenTwoDates(String begin, String end) {
        String[] splitBeginStr = begin.split(":");
        int hrBegin = Integer.parseInt(splitBeginStr[0]);
        int minBegin = Integer.parseInt(splitBeginStr[1]);

        String[] splitEndStr = end.split(":");
        int hrEnd = Integer.parseInt(splitEndStr[0]);
        int minEnd = Integer.parseInt(splitEndStr[1]);

        Calendar beginCal = Calendar.getInstance();
        beginCal.set(Calendar.HOUR_OF_DAY, hrBegin);
        beginCal.set(Calendar.MINUTE, minBegin);

        Calendar endCal = Calendar.getInstance();
        endCal.set(Calendar.HOUR_OF_DAY, hrEnd);
        endCal.set(Calendar.MINUTE, minEnd);

        Calendar currentCal = Calendar.getInstance();

        if (beginCal.before(currentCal) && currentCal.before(endCal)) {
            return true;
        }//from  w  ww.j  av a2 s. c o m

        return false;
    }
}

Related

  1. formatRelativeTime(String fullRelativeDate)
  2. getRelativeTimeofTweet(String tweetCreatedAt)
  3. relativeDate(String dateString)
  4. getRelativeDate(Date date)
  5. humanFriendlyDate(Date date)
  6. getHumanReadableDateDiff(Date pastDate, boolean unknownIfNull)