I need to basically print every quarter-hour of the day from 00:00 to 23:45 (so 96 different times) in hh:mm format to create a html report. Is there a standard library to do that? Or another way?
JavaScript
x
PrintStream fillStatus = new PrintStream("Report.html");
for (int(int i=0; i <= 116; i++) {
jobStatus[] = FileMonitorLog.getStatusOfJob(i)
fillStatus.println("<tr >");
fillStatus.println("<td>"+hh:mmTime+"</td>");
for (quarter=0; quarter <= 96; quarter++) {
fillStatus.println("<td>"+getHtmlStatus(jobStatus[quarter])."</td>");
Advertisement
Answer
Can be done using the java.time.LocalTime
:
JavaScript
var time = LocalTime.MIN;
do {
System.out.println(time);
time = time.plusMinutes(15);
} while (!time.equals(LocalTime.MIN));
It can also be done with a for
loop, just consider that LocalTime
does not accept 24:00
, so 23:45 + 0:15
results in 00:00
.
The default format used by LocalTime.toString()
is HH:MM
if seconds and fraction of seconds is zero. A DateTimeFormat
can be used to format the tine using a different format.