Java SQL Time Parse stringToTime(String timeString)

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

Description

Returns the Time value of a time string.

License

Open Source License

Parameter

Parameter Description
timeString a <code>String</code> value

Exception

Parameter Description
ParseException an exception

Return

a Time value

Declaration

public static Time stringToTime(String timeString) throws ParseException 

Method Source Code


//package com.java2s;
/*/*www  .  ja  va 2  s .  c om*/
 * Copyright (c) Open Source Strategies, Inc.
 *
 * Opentaps is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Opentaps is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Opentaps.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.sql.Time;

import java.text.DateFormat;
import java.text.ParseException;

import java.text.SimpleDateFormat;

public class Main {
    private static final String TIME_FORMAT = "HH:mm:ss";

    /**
     * Returns the Time value of a time string.
     * @param timeString a <code>String</code> value
     * @return a <code>Time</code> value
     * @throws ParseException 
     */
    public static Time stringToTime(String timeString) throws ParseException {
        DateFormat df = new SimpleDateFormat(TIME_FORMAT);
        return new Time(df.parse(timeString).getTime());
    }
}

Related

  1. string2Time(String time, DateFormat timeFormat)
  2. stringToTime(String data, String dateFormat)
  3. stringToTime(String schedule)
  4. stringToTime(String sTime)
  5. StringToTime(String strDate)