Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.sql.Timestamp;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

public class Main {
    public static String parserTimestamp(Timestamp timestamp) {
        String tsStr = "";
        DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        try {
            tsStr = sdf.format(timestamp);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tsStr;

    }

    public static Timestamp parserTimestamp(String timestamp) {
        Timestamp ts = null;
        try {
            ts = Timestamp.valueOf(timestamp + " " + "00:00:00");
            System.out.println(ts);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ts;
    }
}