Java Yesterday getYesterdayCompactTime()

Here you can find the source of getYesterdayCompactTime()

Description

get Yesterday Compact Time

License

Open Source License

Declaration

public static String getYesterdayCompactTime() 

Method Source Code


//package com.java2s;
import java.text.*;
import java.util.*;

public class Main {
    private static String CurrentTime;

    public static String getYesterdayCompactTime() {
        Calendar cal = Calendar.getInstance();
        cal.add(cal.DATE, -1);/*from w  w w  .j a v a 2  s . co m*/
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        CurrentTime = formatter.format(cal.getTime());
        return CurrentTime;
    }

    public static int getTime(String sDateTime, String eDateTime) throws ParseException {
        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date ssDateTime = myFormatter.parse(sDateTime);
        java.util.Date eeDateTime = myFormatter.parse(eDateTime);
        long l = (eeDateTime.getTime() - ssDateTime.getTime());
        long day = l / (24 * 60 * 60 * 1000);
        return (int) day;
    }
}

Related

  1. getYesterday(Date date)
  2. getYesterday(Date date, Boolean isBefore, int interval)
  3. getYesterDay(String pattern)
  4. getYesterday6AM()
  5. getYesterdayBegin()
  6. getYesterdayDate(Date date)
  7. getYesterdayDate(int day)
  8. getYesterdayDate(String format)
  9. getYesterdayDateAsString()