Java SQL Time str2dateTime(String handedate)

Here you can find the source of str2dateTime(String handedate)

Description

strdate Time

License

Apache License

Parameter

Parameter Description
handedate a parameter

Declaration

public static Timestamp str2dateTime(String handedate) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.sql.Timestamp;

public class Main {
    static public SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");

    /**/*  w  w  w . jav  a 2  s .  com*/
     * @param handedate
     * @return
     */
    public static Timestamp str2dateTime(String handedate) {
        Timestamp time = null;
        try {
            java.util.Date date = str2utilDate(handedate);
            java.util.Date now = new java.util.Date();
            date.setHours(now.getHours());
            date.setMinutes(now.getMinutes());
            date.setSeconds(now.getSeconds());
            time = new Timestamp(date.getTime());
            return time;
        } catch (Exception e) {
            System.out.println("DateUtil.str2dateTime(str) Error:e = " + e);
            return null;
        }
    }

    public static java.util.Date str2utilDate(String str) {
        try {
            java.util.Date udate = yyyyMMdd.parse(str);
            return udate;
        } catch (Exception e) {
            System.out.println("DateUtil.str2utilDate(str) Error:e = " + e);
            return null;
        }
    }
}

Related

  1. serialize(LocalDateTime date)
  2. serializeSqlTime(Time time)
  3. setTime(PreparedStatement statement, int index, Date value)
  4. sqlDateTimeAdd(java.util.Date date, long milliseconds)
  5. sqlTime()
  6. StrToDateTime(String val)
  7. strToTime(String strDate)
  8. toDate(TimeZone tz, int days)
  9. toDateFromTime(String time)