Here you can find the source of stringToTime(String timeString)
Parameter | Description |
---|---|
timeString | a <code>String</code> value |
Parameter | Description |
---|---|
ParseException | an exception |
Time
value
public static Time stringToTime(String timeString) throws ParseException
//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()); } }