Java SQL Time Create getSQLTime(String timeString)

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

Description

get SQL Time

License

Apache License

Declaration

public static Time getSQLTime(String timeString) 

Method Source Code

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

import java.sql.Time;
import java.util.Calendar;

public class Main {
    /**/*w  ww . j a  v a  2s  . c om*/
     * transform date from format like "HH:MM" to sql date
     * @param @param timeString:
     * @throws
     */
    public static Time getSQLTime(String timeString) {
        String[] timeStrings = timeString.split(":");
        int hour = Integer.parseInt(timeStrings[0]);
        int minute = Integer.parseInt(timeStrings[1]);
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, minute);
        Time time = new Time(calendar.getTimeInMillis());
        return time;
    }
}

Related

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