Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.ParseException;

public class Main {
    public static long toTimestamp(String date) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        java.util.Date temp;

        try {
            temp = sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return -1;
        }
        return temp.getTime();

    }
}