code: public static long parseTimePeriod(String period)
     {
        try
        {
           String s = period.toLowerCase();
           long factor;
  
           // look for suffix
           if (s.endsWith("msec"))
           {
              s = s.substring(0, s.lastIndexOf("msec"));
              factor = MSEC;
           }
           else if (s.endsWith("sec"))
           {
              s = s.substring(0, s.lastIndexOf("sec"));
              factor = SECS;
           }
           else if (s.endsWith("min"))
           {
              s = s.substring(0, s.lastIndexOf("min"));
              factor = MINS;
           }
           else if (s.endsWith("h"))
           {
              s = s.substring(0, s.lastIndexOf("h"));
              factor = HOUR;
           }
           else
           {
              factor = 1;
           }
           return Long.parseLong(s) * factor;
        }
        catch (RuntimeException e)
        {
           // thrown in addition when period is 'null'
           throw new NumberFormatException("For input time period: '" + period + "'");
        }
     }
docs: Parses a time period into a long.
  
  Translates possible [msec|sec|min|h] suffixes
  
  For example: "1" -> 1 (msec) "1msec -> 1 (msec) "1sec" -> 1000 (msecs) "1min" -> 60000 (msecs) "1h" -> 3600000
  (msecs)
  
  Accepts negative periods, e.g. "-1"
  
  @param period the stringfied time period
  @return the parsed time period as long
  @throws NumberFormatException