1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| //
// Horloge.java
//
// Ecrire un programme qui pour un nombre de secondes donné
// calcule et affiche son équivalent en nombre de jours, d'heures,
// de minutes et de secondes.
import java.util.*;
import java.text.*;
import java.lang.Exception.*;
public class Horloge {
public static void main(String[] args) {
int lu = 100;
String secondes;
try
{
System.out.println( "Entrez une durée en secondes à convertir: " );
lu = System.in.read();
}
catch ( Exception e )
{
e.printStackTrace();
}
// sdf simpledateformat( lu ) de int secondes en jours hh mm ss
// formater sdf pour avoir les seconde
SimpleDateFormat formatter = new SimpleDateFormat ("HH:mm:ss");
String formattedDate = formatter.format(lu);
System.out.println( "ça donne: " + formattedDate );
}
} |
Partager