package com.censoredsoftware.censoredlib.util;

import java.text.DecimalFormat;

public class Times
{
	/**
	 * Return the seconds since the provided time.
	 * 
	 * @param time The provided time.
	 * @return Seconds.
	 */
	public static double getSeconds(long time)
	{
		return (double) Math.abs((time - System.currentTimeMillis()) / 1000);
	}

	/**
	 * Return the minutes since the provided time.
	 * 
	 * @param time The provided time.
	 * @return Minutes.
	 */
	public static double getMinutes(long time)
	{
		return (double) Math.abs((time - System.currentTimeMillis()) / 60000);
	}

	/**
	 * Return the hours since the provided time.
	 * 
	 * @param time The provided time.
	 * @return Hours.
	 */
	public static double getHours(long time)
	{
		return (double) Math.abs((time - System.currentTimeMillis()) / 3600000);
	}

	/**
	 * Return a readable String of the amount of time since a provided time.
	 * 
	 * @param time The provided time.
	 * @param round Round to an int.
	 * @return The readable String.
	 */
	public static String getTimeTagged(long time, boolean round)
	{
		DecimalFormat format = round ? new DecimalFormat("#") : new DecimalFormat("#.##");
		if(getHours(time) >= 1) return format.format(getHours(time)) + "h";
		else if(Double.valueOf(format.format(getMinutes(time))) >= 1) return format.format(getMinutes(time)) + "m";
		else return format.format(getSeconds(time)) + "s";
	}
}

@@ -72,16 +72,54 @@
 lFormat;
+%0Aimport java.util.concurrent.TimeUnit;
 %0A%0Apublic
@@ -313,33 +313,55 @@
 rn (double) 
-Math.abs(
+TimeUnit.MILLISECONDS.toSeconds
 (time - Syst
@@ -387,16 +387,8 @@
 s())
- / 1000)
 ;%0A%09%7D
@@ -569,33 +569,55 @@
 rn (double) 
-Math.abs(
+TimeUnit.MILLISECONDS.toMinutes
 (time - Syst
@@ -643,17 +643,8 @@
 s())
- / 60000)
 ;%0A%09%7D
@@ -827,17 +827,37 @@
 le) 
-Math.abs(
+TimeUnit.MILLISECONDS.toHours
 (tim
@@ -891,19 +891,8 @@
 s())
- / 3600000)
 ;%0A%09%7D
@@ -1146,19 +1146,20 @@
  round)%0A
-
 %09%7B%0A
+%0A
 %09%09Decima

Update time stuff a bit.