Java Day of getTwoDay(String sj1, String sj2)

Here you can find the source of getTwoDay(String sj1, String sj2)

Description

get Two Day

License

Apache License

Declaration

public static String getTwoDay(String sj1, String sj2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    public static String getTwoDay(String sj1, String sj2) {
        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
        long day = 0;
        try {/*from  w  w w .j  a  va2  s.  c  o m*/
            Date date = myFormatter.parse(sj1);
            Date mydate = myFormatter.parse(sj2);
            day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
        } catch (Exception e) {
            return "";
        }
        return day + "";
    }

    public static String getTime() {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = formatter.format(currentTime);
        String min;
        min = dateString.substring(14, 16);
        return min;
    }
}

Related

  1. getTargetDay(String day, int beforeOrAfterDays)
  2. getTheDayBefore(Date date)
  3. getThursday(String date)
  4. getTimeOfDaySeconds()
  5. getTimestamp(String format, Integer daysInFuture)
  6. getTwoDay(String sj1, String sj2)
  7. getTwoDay2String(String startDate, String endDate, Format format)
  8. getWorkingDay(Calendar d1, Calendar d2)
  9. getYesday()