Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getYestoday(Date date) {
        return addDay(date, -1);
    }

    public static Date getYestoday() {
        return getYestoday(new Date());
    }

    public static Date addDay(Date date, int days) {
        return add(date, Calendar.DAY_OF_MONTH, days);
    }

    public static Date add(Date date, int field, int amount) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(field, amount);
        return c.getTime();
    }
}