Handle zero time diff better

This commit is contained in:
Olof Larsson 2013-10-10 14:29:20 +02:00
parent 480fcdc8b9
commit 5f692d215a

View File

@ -71,6 +71,7 @@ public class TimeDiffUtil
if (!matcherFull.matches()) throw new NullPointerException("Invalid time diff format.");
LinkedHashMap<TimeUnit, Long> ret = new LinkedHashMap<TimeUnit, Long>();
if (formated.equals("0")) return ret;
Matcher matcherPart = patternPart.matcher(formated);
while (matcherPart.find())
@ -167,6 +168,11 @@ public class TimeDiffUtil
String comma = String.format(commaFormat, Txt.parse(color));
String and = String.format(andFormat, Txt.parse(color));
if (unitcounts.isEmpty())
{
return formated(TimeUnit.SECOND, 0, entryFormat);
}
List<String> parts = new ArrayList<String>();
for (Entry<TimeUnit, Long> entry : unitcounts.entrySet())
{