From 4049da97fbb988c7bc658ac4f1ef6326e29c8f25 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 30 Jun 2010 13:00:25 +0300 Subject: [PATCH] time value to support parsing days as well --- .../main/java/org/elasticsearch/common/unit/TimeValue.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/TimeValue.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/TimeValue.java index 13410a67637..085a09bd65e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/TimeValue.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/unit/TimeValue.java @@ -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); }