Java Milliseconds getMillisecondsFromTimeString(String timeString)

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

Description

get Milliseconds From Time String

License

Open Source License

Parameter

Parameter Description
timeString a parameter

Declaration

public static long getMillisecondsFromTimeString(String timeString) 

Method Source Code

//package com.java2s;
/*/*w ww . ja  va2  s  .  co  m*/
 * @(#) Helpers.java
 *
 * Created on 22.04.2006 by Daniel Becker (quippy@quippy.de)
 *
 *-----------------------------------------------------------------------
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */

public class Main {
    /**
     * @since 03.04.2011
     * @param timeString
     * @return
     */
    public static long getMillisecondsFromTimeString(String timeString) {
        int minIndex = timeString.indexOf(':');
        int min = Integer.parseInt(timeString.substring(0, minIndex).trim());
        String secString = timeString.substring(minIndex + 1);
        int secIndex = secString.indexOf(':');
        if (secIndex == -1)
            secIndex = secString.length();
        int sec = Integer.parseInt(secString.substring(0, secIndex).trim());
        return (min * 60 + sec) * 1000L;
    }
}

Related

  1. getMilliSecondBetween(long start, long end)
  2. getMillisecondDay()
  3. getMilliSeconds(String input)
  4. getMilliseconds(String time)
  5. getMilliseconds(String unixtime)
  6. getMilliSecs()
  7. getMillisFromByteArray(byte[] buff, int offset)
  8. getMillisPartFromNanos(long nanos)
  9. getMillisSinceInit()