Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String ymdhm2Timestamp(String dateString) throws ParseException {
        String timeStamp = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");
        Date d;
        try {
            d = sdf.parse(dateString);
            long l = d.getTime() / 1000;
            timeStamp = String.valueOf(l);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return timeStamp;
    }
}