Java SQL Time Create getSQLTime(String value)

Here you can find the source of getSQLTime(String value)

Description

get SQL Time

License

Open Source License

Declaration

public static Time getSQLTime(String value) throws ParseException 

Method Source Code

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

import java.sql.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    public static Time getSQLTime(String value) throws ParseException {
        Time result = null;// w  w  w  . j av a2  s  .  c o  m
        assert value != null : "[DSU] invalid value : " + value;

        if (value != null) {
            DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");
            result = new Time(getDate(TIME_FORMAT, value).getTime());

        }
        return result;
    }

    public static java.util.Date getDate(DateFormat format, String value) throws ParseException {
        java.util.Date result = null;
        assert value != null : "[DSU] invalid value : " + value;

        if (value != null) {
            result = format.parse(value);
        }
        return result;
    }

    public static java.util.Date getDate(String value) throws ParseException {
        DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        return getDate(DATE_FORMAT, value);
    }
}

Related

  1. getSqlTime(int hour, int minute, int second)
  2. getSQLTime(String timeString)
  3. getSQLTimeFromString(String s)
  4. getSqlTimeFromTimeNumber(int time)
  5. getSysDateTimeMillis()
  6. getSystemCurrentTimeMillis()