{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());
}
}
A Voir sur le même Sujet:
- soustraire heures java
- calcul+millisecondes+java
- duree en java
- classe duree en java
- calculer une durée temps java
- graphe calcul io en milliseconde
- java durée
- duree en java en milliseconde
- java obtenir date à partir d'une durée
- calculer la durée en nombre de jour java