Here you can find the source of parseHourAndMinute(String value)
Parameter | Description |
---|---|
value | a parameter |
public static Long parseHourAndMinute(String value)
//package com.java2s; // it under the terms of the GNU Affero General Public License as published by public class Main { private static final long MILLIS_PER_MINUTE = 60L * 1000L; private static final long MILLIS_PER_HOUR = 60L * MILLIS_PER_MINUTE; /**//from w ww . jav a 2s. c o m * @param value * @return */ public static Long parseHourAndMinute(String value) { value = value.trim(); String[] comp = value.split(":"); if (comp.length != 2) { return 0L; // invalid, should report as error... } try { int hours = Integer.parseInt(comp[0]); int minutes = Integer.parseInt(comp[1]); return (hours * MILLIS_PER_HOUR) + (minutes * MILLIS_PER_MINUTE); } catch (NumberFormatException e) { return 0L; // invalid, should report as error... } } }