Add age functions.

This commit is contained in:
Christian P. MOMON 2010-08-18 01:18:55 +02:00
parent 86b4ffd042
commit ef1ea08532

99
src/fr/devinsy/util/SimpleChronometer.java Executable file → Normal file
View file

@ -47,4 +47,103 @@ public class SimpleChronometer
//
return(result);
}
/**
*
*/
static public String shortHumanString(long interval)
{
String result;
if (interval < 1000)
{
result = interval + " ms";
}
else if (interval < 60*1000)
{
result = interval/1000 + " s";
}
else if (interval < 60*60*1000L)
{
result = interval/(60*1000L) + " mn";
}
else if (interval < 2*60*60*1000L)
{
result = interval/(60*1000L) + " heure";
}
else if (interval < 24*60*60*1000L)
{
result = interval/(60*60*1000L) + " heures";
}
else if (interval < 2*24*60*60*1000L)
{
result = interval/(24*60*60*1000L) + " jour";
}
else if (interval < 7*24*60*60*1000L)
{
result = interval/(24*60*60*1000L) + " jours";
}
else if (interval < 2*7*24*60*60*1000L)
{
result = interval/(7*24*60*60*1000L) + " semaine";
}
else if (interval < 30*24*60*60*1000L)
{
result = interval/(7*24*60*60*1000L) + " semaines";
}
else if (interval < 52*7*24*60*60*1000L)
{
result = interval/(30*24*60*60*1000L) + " mois";
}
else if (interval < 2*52*7*24*60*60*1000L)
{
result = interval/(52*7*24*60*60*1000L) + " année";
}
else
{
result = interval/(52*7*24*60*60*1000L) + " années";
}
//
return(result);
}
/**
* TO BE COMPLETED.
*/
static public String humanString(long interval)
{
String result;
if (interval < 1000)
{
result = interval + "ms";
}
else if (interval < 60*1000)
{
result = interval/1000 + "," + interval%1000 + "s";
}
else if (interval < 60*60*1000)
{
result = interval/1000 + "," + interval%1000 + "s";
}
else if (interval < 24*60*60*1000)
{
result = interval/1000 + "," + interval%1000 + "s";
}
else if (interval < 7*24*60*60*1000)
{
result = interval/1000 + "," + interval%1000 + "s";
}
else // if (interval < 7*24*60*60*1000)
{
result = interval/1000 + "," + interval%1000 + "s";
}
//
return(result);
}
}