Here you can find the source of getMilliseconds(String time)
public static long getMilliseconds(String time)
//package com.java2s; /* /*from w w w.ja v a 2 s. c o m*/ * * **************************************************************************** * Copyright 2003*2004 Intecs **************************************************************************** * This file is part of TOOLBOX. * * TOOLBOX 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. * * TOOLBOX 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 TOOLBOX; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **************************************************************************** * File Name: $RCSfile: Util.java,v $ * TOOLBOX Version: $Name: HEAD $ * File Revision: $Revision: 1.1.1.1 $ * Revision Date: $Date: 2006/06/13 15:02:26 $ * */ public class Main { public static final int MILLISECONDS = 1000; public static final int SECONDS = 60; public static final int MINUTES = 60; public static final int HOURS = 24; public static final int DAYS = 7; public static long getMilliseconds(String time) { int lastPos = time.length() - 1; long t = Long.parseLong(time.substring(0, lastPos)); char c = time.charAt(lastPos); switch (c) { case 's': return t * MILLISECONDS; case 'm': return t * SECONDS * MILLISECONDS; case 'h': return t * MINUTES * SECONDS * MILLISECONDS; case 'd': return t * HOURS * MINUTES * SECONDS * MILLISECONDS; case 'w': return t * DAYS * HOURS * MINUTES * SECONDS * MILLISECONDS; default: throw new IllegalArgumentException("Unknown marker: " + c); } } }