Here you can find the source of valueOf(String s)
public static long valueOf(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static long valueOf(String s) { long time = 0L; for (String st : s.split(" ")) { if (st.endsWith("d")) { time += Long.valueOf(st.substring(0, st.length() - 1)) * 86400L; continue; }//from w w w.j a v a2s . c o m if (st.endsWith("s")) { time += Long.valueOf(st.substring(0, st.length() - 1)); continue; } if (st.endsWith("m")) { time += Long.valueOf(st.substring(0, st.length() - 1)) * 60L; continue; } if (st.endsWith("h")) { time += Long.valueOf(st.substring(0, st.length() - 1)) * 3600L; continue; } throw new NumberFormatException(st + " is not a time value!"); } return time; } }