Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static final long RELEASE_ZERO_TIMESTAMP = 1298908800000L;
    private static long TIME_CALIBRATOR = 0;

    public static void setHttpResponseDate(String date) {
        try {
            DateFormat fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);

            Date d = fmt.parse(date.trim());

            if (d.getTime() < RELEASE_ZERO_TIMESTAMP)
                return;

            TIME_CALIBRATOR = d.getTime() - System.currentTimeMillis();

        } catch (Exception e) {
            // just ignore
        } catch (Error error) {
            // just ignore
        }
    }

    public static long currentTimeMillis() {
        return System.currentTimeMillis() + TIME_CALIBRATOR;
    }
}