Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.TimeZone;

public class Main {
    public static Long getYesterday() {
        Calendar yesterday = Calendar.getInstance();
        yesterday.setTimeZone(TimeZone.getDefault());

        yesterday.set(Calendar.SECOND, 0);
        yesterday.set(Calendar.MINUTE, 0);
        yesterday.set(Calendar.HOUR_OF_DAY, 1);
        yesterday.set(Calendar.MILLISECOND, 0);

        int day = yesterday.get(Calendar.DAY_OF_YEAR);

        yesterday.set(Calendar.DAY_OF_YEAR, day - 1);

        return yesterday.getTimeInMillis();
    }
}