Java Milliseconds getMilliSeconds(String input)

Here you can find the source of getMilliSeconds(String input)

Description

get Milli Seconds

License

Open Source License

Declaration

public static long getMilliSeconds(String input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long getMilliSeconds(String input) {
        if (input.toLowerCase().endsWith("h")) {
            return Long.parseLong(input.replace("h", "")) * 60 * 60 * 1000;
        } else if (input.toLowerCase().endsWith("m")) {
            return Long.parseLong(input.replace("m", "")) * 60 * 1000;

        } else if (input.toLowerCase().endsWith("d")) {
            return Long.parseLong(input.replace("d", "")) * 24 * 60 * 60 * 1000;

        } else if (input.toLowerCase().endsWith("w")) {
            return Long.parseLong(input.replace("w", "")) * 7 * 24 * 60 * 60 * 1000;

        } else if (input.toLowerCase().endsWith("s")) {
            return Long.parseLong(input.replace("s", "")) * 1000;
        } else {/*  w ww  . j  a v a2 s .c o  m*/
            return Long.parseLong(input);
        }
    }
}

Related

  1. getMilliSecond(Date d1, Date d2)
  2. getMillisecond(Date date)
  3. getMillisecond(String forDate)
  4. getMilliSecondBetween(long start, long end)
  5. getMillisecondDay()
  6. getMilliseconds(String time)
  7. getMilliseconds(String unixtime)
  8. getMillisecondsFromTimeString(String timeString)
  9. getMilliSecs()