Java SQL Time From toTime(String str)

Here you can find the source of toTime(String str)

Description

to Time

License

Open Source License

Declaration

public static Time toTime(String str) 

Method Source Code


//package com.java2s;

import java.sql.Time;

public class Main {
    public static Time toTime(String str) {

        if (str == null) {
            return null;
        }//w w  w  . j  a  va2s . c o  m

        try {
            return (str.length() == 5 ? Time.valueOf(str + ":00") : Time.valueOf(str));
        } catch (Exception e) {
            return null;
        }

    }
}

Related

  1. toTime(LocalTime localTime)
  2. toTime(LocalTime localTime)
  3. toTime(Object object, Object oDefault)
  4. toTime(Object value)
  5. toTime(String format, String str)
  6. toTime(String value)
  7. toTime2(int value, int fraction, int width)
  8. toTime2(int value, int nanos)
  9. toTimeIso(Date date)