Several improvements
This commit is contained in:
parent
3321ba3981
commit
e5580d3f89
@ -21,6 +21,7 @@
|
|||||||
package org.nanoboot.powerframework.time.moment;
|
package org.nanoboot.powerframework.time.moment;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class stores date time without time zone information.
|
* 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
|
* @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) {
|
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());
|
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
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -25,7 +25,7 @@ package org.nanoboot.powerframework.time.utils;
|
|||||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||||
* @since 0.0.0
|
* @since 0.0.0
|
||||||
*/
|
*/
|
||||||
class RemainingTimeCalculator {
|
public class RemainingTimeCalculator {
|
||||||
private long startNanoTime = 0;
|
private long startNanoTime = 0;
|
||||||
private long total;
|
private long total;
|
||||||
private long done = 0;
|
private long done = 0;
|
||||||
@ -63,6 +63,6 @@ class RemainingTimeCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
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.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user