Android Yesterday Get getYesterdayFormattedTime()

Here you can find the source of getYesterdayFormattedTime()

Description

get Yesterday Formatted Time

Declaration

public static String getYesterdayFormattedTime() 

Method Source Code

//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import java.util.Locale;

public class Main {
    public static String getYesterdayFormattedTime() {

        Calendar calendar = getCurrentCalendar();
        calendar.add(Calendar.HOUR_OF_DAY, -9);
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ssz");
        String result = format.format(calendar.getTime());
        String standardName = "";
        if (result.contains("JST")) {
            standardName = "JST";
            result = result.replaceAll(standardName, "+09:00");
        } else if (result.contains("GMT")) {
            standardName = "GMT";
            result = result.replaceAll(standardName, "");
        }/*from  ww  w.j  a v a2  s  .c o m*/
        return result;
    }

    public static Calendar getCurrentCalendar() {

        Calendar currentCal = new GregorianCalendar(Locale.JAPAN);

        return currentCal;
    }
}

Related

  1. getYestoday(String sourceDate, String format)
  2. getYestoday(String sourceDate, String format)
  3. getFormatYestoday(String format)
  4. isYesterday(long date)
  5. getYesterday()