Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     * @param time
     * @param format "MMM dd yyyy HH:mm:ss.SSS zzz"
     * @return
     */
    public static long getEpochTime(String time, String format) {
        try {
            SimpleDateFormat df = new SimpleDateFormat(format);
            Date date = df.parse(time);
            return date.getTime() / 1000;
        } catch (Exception e) {
            return 0;
        }
    }
}