code: static public String serializeTime(final long millisecondTime) throws NumberFormatException
     {
        if (millisecondTime >= 604800000 && (millisecondTime % 604800000) == 0)
        {
           return String.valueOf(millisecondTime / 604800000) + "w";
        }
        else if (millisecondTime >= 86400000 && (millisecondTime % 86400000) == 0)
        {
           return String.valueOf(millisecondTime / 86400000) + "d";
        }
        else if (millisecondTime >= 3600000 && (millisecondTime % 3600000) == 0)
        {
           return String.valueOf(millisecondTime / 3600000) + "h";
        }
        else if (millisecondTime >= 60000 && (millisecondTime % 60000) == 0)
        {
           return String.valueOf(millisecondTime / 60000) + "m";
        }
        else if (millisecondTime >= 1000 && (millisecondTime % 1000) == 0)
        {
           return String.valueOf(millisecondTime / 1000) + "s";
        }
  
        return String.valueOf(millisecondTime) + "ms";
     }
docs: Serialize given time in milliseconds and return a time as formated time in ms, s, h,d,w.
  Formats : ms - milliseconds, s - seconds, h hours, w - weeks.
  
  @param millisecondTime
  - time in milliseconds
  @return String
  - time as formated time in milliseconds
  @throws NumberFormatException