Scale Time is expressed in the format“H:MM:SS.LLL”. The first digit expresses ho
ID: 3613115 • Letter: S
Question
Scale Time is expressed in the format“H:MM:SS.LLL”. The first digit expresses hours (H), the next two, minutes (MM), the next two, seconds (SS) and the last three, after a decimal point, milliseconds(LLL) (1000 millisecond equals 1 second).Please i want the code ofthat problem. Thanks A lot of Scale Time is expressed in the format“H:MM:SS.LLL”. The first digit expresses hours (H), the next two, minutes (MM), the next two, seconds (SS) and the last three, after a decimal point, milliseconds(LLL) (1000 millisecond equals 1 second).
Please i want the code ofthat problem. Thanks A lot of
Explanation / Answer
System.out.println(s);
}
private static void doTime() throwsInterruptedException{
// date and time usethe noargs Time() constructor like this:
prt("CURRENTTIME");
SimpleDateFormat("HH/dd/yyyy HH:mm:ss");
String nowFormatted =formatPattern.format(now);
// You can return thenumber of milliseconds in the Date
// as a long, usingthe getTime() method. For example,
// to time a block ofcode, you might do this
prt("USE getTime() TORETURN MILLISECONDS");
prt(" Start Time: " + startTime);
// ....
// Insert any "timedcode" here...
// ...
System.out.print(" ");
for (int i = 0; i< 100; i++) {
System.out.print(".");
//Pause for 5 seconds
Thread.sleep(5000);
}
prt();
prt(" EndTime : " + endTime);
long elapsed_time =endTime.getTime() - startTime.getTime();
prt(" That took" + elapsed_time + " milliseconds");
prt();
long totalTimeMillis= elapsed_time / 1000;
StringtotalTimeSeconds = Integer.toString((int)(totalTimeMillis %60));
StringtotalTimeMinutes = Integer.toString((int)((totalTimeMillis % 3600)/ 60));
String totalTimeHours= Integer.toString((int)(totalTimeMillis / 3600));
for (int i = 0; i< 2; i++) {
if (totalTimeSeconds.length() < 2) {
totalTimeSeconds = "0" + totalTimeSeconds;
}
if (totalTimeMinutes.length() < 2) {
totalTimeMinutes = "0" + totalTimeMinutes;
}
if (totalTimeHours.length() < 2) {
totalTimeHours = "0" + totalTimeHours;
}
}
prt("Formattedoutput : " + totalTimeHours + " hours "+ totalTimeMinutes + " minutes "+ totalTimeSeconds + "minutes ");
prt("RETRIEVEMILLISECONDS");
long n =y.getTime();
prt(" Number ofmilliseconds since 1/1/1970 (GMT) : " + n);
}
ITS HELPFUL TO YOU.........
public static void main(String[] args) {
prt();
try {
doTime);
} catch (Exception e){
e.printStackTrace();
}
}
}