
{filelink=5610}
public class FormatageMillis {
public final static long UNE_SECOND = 1000;
public final static long UNE_MINUTE = UNE_SECOND * 60;
public final static long UNE_HOUR = UNE_MINUTE * 60;
public final static long UN_JOUR = UNE_HOUR * 24;
public static void millisecondADHMS(long durée) {
long temp = 0;
if (durée >= UNE_SECOND) {
temp = durée / UN_JOUR;
if (temp > 0) {
System.out.print(temp + " jour");
if (temp > 1) {
System.out.print("s");
}
}
temp = durée / UNE_HOUR;
if (temp > 0) {
System.out.print(temp + " heure");
if (temp > 1) {
System.out.print("s");
}
}
temp = durée / UNE_MINUTE;
if (temp > 0) {
System.out.print( temp + " minute");
if (temp > 1) {
System.out.print("s");
}
}
temp = durée / UNE_SECOND;
if (temp > 0) {
System.out.print(" second");
if (temp > 1) {
System.out.print("s");
}
}
}
}
public static void main(String args[]) {
millisecondADHMS(System.currentTimeMillis());
}
}