Several improvements

This commit is contained in:
Robert Vokac 2023-08-05 16:50:38 +02:00
parent 3321ba3981
commit e5580d3f89
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
2 changed files with 25 additions and 3 deletions

View File

@ -21,6 +21,7 @@
package org.nanoboot.powerframework.time.moment;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
/**
* This class stores date time without time zone information.
@ -55,12 +56,33 @@ public final class LocalDateTime extends DateTime {
*
* @param ldt java.time.LocalDateTime instance
*
* @return a java.time.LocalDateTime instance from this object
* @return a org.nanoboot.powerframework.time.moment.LocalDateTime instance from this object
*/
public static LocalDateTime toPowerLocalDateTime(java.time.LocalDateTime ldt) {
return new LocalDateTime(ldt.getYear(), ldt.getDayOfMonth(), ldt.getDayOfMonth(), ldt.getHour(), ldt.getMinute(), ldt.getSecond(), ldt.getSecond());
}
/**
*
** Creates new LocalDateTime from java.util.Date.
* @param javaUtilDate java.util.Date instance
*
* @return a org.nanoboot.powerframework.time.moment.LocalDateTime instance from this object
*/
public static LocalDateTime convertJavaUtilDateToPowerLocalDateTime(java.util.Date javaUtilDate) {
Calendar cal = Calendar.getInstance();
cal.setTime(javaUtilDate);
return new LocalDateTime(
cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH) + 1,
cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY),
cal.get(Calendar.MINUTE),
cal.get(Calendar.SECOND),
cal.get(Calendar.MILLISECOND));
}
/**
* Constructor
*

View File

@ -25,7 +25,7 @@ package org.nanoboot.powerframework.time.utils;
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
* @since 0.0.0
*/
class RemainingTimeCalculator {
public class RemainingTimeCalculator {
private long startNanoTime = 0;
private long total;
private long done = 0;
@ -63,6 +63,6 @@ class RemainingTimeCalculator {
}
public String getMessage() {
return "Time elapsed: " + this.elapsedSecondSinceStart() + " seconds. Time left: " + this.remainingSecondsUntilEnd() + " seconds. Done: " + this.getDoneCount() + " tasks.";
return "Elapsed=" + this.elapsedSecondSinceStart() + " seconds Left=" + this.remainingSecondsUntilEnd() + " seconds Done=" + this.getDoneCount() + " tasks.";
}
}