Java Timestamp Parse stringToTimesTamp(String yMd, boolean isEndTime)

Here you can find the source of stringToTimesTamp(String yMd, boolean isEndTime)

Description

string To Times Tamp

License

Open Source License

Declaration

public static Timestamp stringToTimesTamp(String yMd, boolean isEndTime) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.*;

public class Main {
    public static Timestamp stringToTimesTamp(String yMd, boolean isEndTime) {
        if (yMd == null || yMd.length() == 0) {
            return null;
        }//  w  w w  .j  a  v  a 2  s. co  m
        Timestamp ts = new Timestamp(System.currentTimeMillis());
        StringBuffer buf = new StringBuffer();
        buf.append(yMd);
        if (isEndTime) {
            buf.append(" 23:59:59");
        } else {
            buf.append(" 00:00:00");
        }
        try {
            ts = Timestamp.valueOf(buf.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ts;
    }
}

Related

  1. stringToTimeStamp(String dateTimeString, String dateTimeFormat, TimeZone tz, Locale locale)
  2. stringToTimestamp(String marcTimestamp)
  3. stringToTimestamp(String sTimestamp)
  4. stringToTimestamp(String ts)
  5. stringToTimestamp(String value)
  6. stripToMinutes(java.sql.Timestamp timestamp)