time value to support parsing days as well

This commit is contained in:
kimchy 2010-06-30 13:00:25 +03:00
parent 088e0b5a64
commit 4049da97fb
1 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,7 @@ import java.io.Serializable;
import java.util.concurrent.TimeUnit;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
public class TimeValue implements Serializable, Streamable {
@ -231,8 +231,10 @@ public class TimeValue implements Serializable, Streamable {
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 1000);
} else if (sValue.endsWith("m")) {
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 60 * 1000);
} else if (sValue.endsWith("H")) {
} else if (sValue.endsWith("H") || sValue.endsWith("h")) {
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 60 * 60 * 1000);
} else if (sValue.endsWith("d")) {
millis = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * 24 * 60 * 60 * 1000);
} else {
millis = Long.parseLong(sValue);
}