Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f52a6e3d99 | ||
|
a96c15cbaa | ||
|
8c8fd9b88d | ||
|
abeeb87cbf | ||
|
e5580d3f89 | ||
|
3321ba3981 | ||
|
d60c3db582 | ||
|
62ab3fb24f | ||
|
8c7305d98b |
107
Jenkinsfile
vendored
Normal file
107
Jenkinsfile
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
pipeline
|
||||
/*
|
||||
Power Framework
|
||||
|
||||
Requirements:
|
||||
|
||||
Maven is Installed
|
||||
|
||||
Java 19 is installed
|
||||
|
||||
*/
|
||||
{
|
||||
agent any
|
||||
environment {
|
||||
AAA = 'aaa'
|
||||
}
|
||||
stages
|
||||
{
|
||||
stage('Build')
|
||||
{
|
||||
steps {
|
||||
|
||||
echo "*** Building ${env.JOB_NAME} ***"
|
||||
sh '''
|
||||
#!/bin/bash
|
||||
echo JOB_NAME=$JOB_NAME
|
||||
|
||||
case $BRANCH_NAME in
|
||||
|
||||
master | deploy_prod)
|
||||
mvn clean install
|
||||
;;
|
||||
|
||||
develop | jenkins | deploy_test)
|
||||
echo Branch $BRANCH_NAME is supported. Continuing.
|
||||
version=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
|
||||
echo version=$version
|
||||
case "$version" in
|
||||
*"SNAPSHOT"*) echo echo version is OK ;;
|
||||
* ) echo echo "You cannot build releases on Jenkins, only snapshots!"&&exit 1 ;;
|
||||
esac
|
||||
mvn clean deploy
|
||||
;;
|
||||
|
||||
*)
|
||||
echo Branch $BRANCH_NAME is not supported. A failure happened. Exiting.
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Build of $JOB_NAME was successful"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy')
|
||||
{
|
||||
steps {
|
||||
echo "*** Deploying ${env.JOB_NAME} ***"
|
||||
|
||||
sh '''
|
||||
#!/bin/bash
|
||||
|
||||
echo "Nothing to do"
|
||||
exit
|
||||
|
||||
case $BRANCH_NAME in
|
||||
|
||||
master | deploy_prod)
|
||||
echo Branch $BRANCH_NAME is supported. Continuing.
|
||||
TOMCAT_HOME=$TOMCAT10_HOME
|
||||
systemdService=tomcat10
|
||||
;;
|
||||
|
||||
develop | jenkins | deploy_test)
|
||||
echo Branch $BRANCH_NAME is supported. Continuing.
|
||||
TOMCAT_HOME=$TOMCAT10_TEST_HOME
|
||||
systemdService=tomcat10test
|
||||
;;
|
||||
|
||||
*)
|
||||
echo Branch $BRANCH_NAME is not supported. A failure happened. Exiting.
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
'''
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
env.color = "${currentBuild.currentResult == 'SUCCESS' ? 'green' : 'red'}"
|
||||
}
|
||||
|
||||
echo 'Sending e-mail.'
|
||||
sh "printenv | sort"
|
||||
emailext body: "<b style=\"color:$COLOR\">${currentBuild.currentResult}</b> - ${env.JOB_NAME} (#${env.BUILD_NUMBER})<br> <ul style=\"margin-top:2px;padding-top:2px;padding-left:30px;\"><li>More info at: <a href=\"${env.BUILD_URL}\">${env.BUILD_URL}</a></li></ul>",
|
||||
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
||||
subject: "Jenkins Build - ${currentBuild.currentResult} - $JOB_NAME (#$BUILD_NUMBER)"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
pom.xml
6
pom.xml
@ -25,12 +25,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
<parent>
|
||||
<groupId>org.nanoboot.essential</groupId>
|
||||
<artifactId>nanoboot-parent</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Power Framework</name>
|
||||
@ -72,7 +72,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<power.version>2.0.0</power.version>
|
||||
<power.version>2.0.1-SNAPSHOT</power.version>
|
||||
<checkstyle.skip>true</checkstyle.skip><!-- TODO: make false-->
|
||||
</properties>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-collections</artifactId>
|
||||
@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// power-framework: Java library with many purposes of usage.
|
||||
// Copyright (C) 2016-2022 the original author or authors.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation;
|
||||
// version 2.1 of the License only.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package org.nanoboot.powerframework.collections;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:robertvokac@nanoboot.org">Robert Vokac</a>
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class CollectionUtils {
|
||||
|
||||
private CollectionUtils() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
public static <T> List<T> reverseList(List<T> list) {
|
||||
|
||||
List<T> reversedList = new ArrayList<>();
|
||||
ListIterator<T> listIterator
|
||||
= list.listIterator(list.size());
|
||||
while (listIterator.hasPrevious()) {
|
||||
T t = listIterator.previous();
|
||||
reversedList.add(t);
|
||||
}
|
||||
return reversedList;
|
||||
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-core</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-db</artifactId>
|
||||
@ -61,13 +61,13 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.28.0</version>
|
||||
<version>${sqlite-jdbc.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-io</artifactId>
|
||||
@ -60,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -33,4 +33,5 @@ module powerframework.io {
|
||||
requires java.logging;
|
||||
requires powerframework.utils;
|
||||
exports org.nanoboot.powerframework.io.bit.base64;
|
||||
exports org.nanoboot.powerframework.io.utils;
|
||||
}
|
||||
|
@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// power-framework: Java library with many purposes of usage.
|
||||
// Copyright (C) 2023-2023 the original author or authors.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation;
|
||||
// version 2.1 of the License only.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package org.nanoboot.powerframework.io.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
private FileUtils() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
public static String readTextFromFile(File file) {
|
||||
if (!file.exists()) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())));
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException("Reading file failed: " + file.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> readLinesFromFile(File file) {
|
||||
return readLinesFromFile(file, false);
|
||||
}
|
||||
|
||||
public static List<String> readLinesFromFile(File file, boolean skipEmptyLines) {
|
||||
String content = readTextFromFile(file);
|
||||
String[] lines = content.split("\\r?\\n|\\r");
|
||||
return Arrays.stream(lines).filter(l -> skipEmptyLines ? !l.trim().isEmpty() : true).collect(
|
||||
Collectors.toList());
|
||||
}
|
||||
|
||||
public static void writeTextToFile(String text, File file) {
|
||||
FileWriter fileWriter;
|
||||
try {
|
||||
fileWriter = new FileWriter(file);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new RuntimeException("Writing to file failed: " + file.getName(), ex);
|
||||
}
|
||||
PrintWriter printWriter = new PrintWriter(fileWriter);
|
||||
printWriter.print(text);
|
||||
printWriter.close();
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-json</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-log</artifactId>
|
||||
@ -56,7 +56,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-mail</artifactId>
|
||||
@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-persistence</artifactId>
|
||||
@ -61,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-random</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-reflection</artifactId>
|
||||
@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-security</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-sql</artifactId>
|
||||
@ -56,7 +56,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -51,7 +51,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-text</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-time</artifactId>
|
||||
@ -76,7 +76,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// power-framework: Java library with many purposes of usage.
|
||||
// Copyright (C) 2016-2022 the original author or authors.
|
||||
@ -17,7 +16,6 @@
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package org.nanoboot.powerframework.time.duration;
|
||||
|
||||
import org.nanoboot.powerframework.random.generators.RandomGenerator;
|
||||
@ -42,6 +40,7 @@ public final class Duration {
|
||||
private static final String PLUS = "+";
|
||||
private static final String MINUS = "-";
|
||||
private static final String COLON = ":";
|
||||
private static final String DOT = ".";
|
||||
|
||||
/**
|
||||
*
|
||||
@ -132,7 +131,7 @@ public final class Duration {
|
||||
java.time.LocalDateTime javaLocalDateTime = universalDateTime.removeUniversalTimeZone().toJavaLocalDateTime();
|
||||
java.time.Duration javaDuration = duration.toJavaDuration();
|
||||
java.time.LocalDateTime newJavaLocalDateTime;
|
||||
if(trueForAddingFalseForSubtracting) {
|
||||
if (trueForAddingFalseForSubtracting) {
|
||||
newJavaLocalDateTime = javaLocalDateTime.plus(javaDuration);
|
||||
} else {
|
||||
newJavaLocalDateTime = javaLocalDateTime.minus(javaDuration);
|
||||
@ -181,7 +180,7 @@ public final class Duration {
|
||||
boolean trueForAddingFalseForSubtracting) {
|
||||
UniversalDateTime universalDateTime = zonedDateTime.toUniversalDateTime();
|
||||
UniversalDateTime newUniversalDateTime;
|
||||
if(trueForAddingFalseForSubtracting) {
|
||||
if (trueForAddingFalseForSubtracting) {
|
||||
newUniversalDateTime = fromUniversalDateTimePlusDurationCreateNewUniversalDateTime(universalDateTime, duration);
|
||||
} else {
|
||||
newUniversalDateTime = fromUniversalDateTimeMinusDurationCreateNewUniversalDateTime(universalDateTime, duration);
|
||||
@ -275,8 +274,8 @@ public final class Duration {
|
||||
* @param string representing the new Duration
|
||||
*/
|
||||
public Duration(String string) {
|
||||
String[] splitString = string.split("\\:+");
|
||||
if(splitString.length != 5) {
|
||||
String[] splitString = string.replace("\\.", ":").split("\\:+");
|
||||
if (splitString.length != 5) {
|
||||
throw new TimeException("Input String has wrong format.");
|
||||
}
|
||||
try {
|
||||
@ -416,14 +415,37 @@ public final class Duration {
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtils.appendObjects(this.isPositive() ? PLUS : MINUS,
|
||||
get(TimeUnit.DAY),
|
||||
String.format("%02d", get(TimeUnit.DAY)),
|
||||
COLON,
|
||||
get(TimeUnit.HOUR),
|
||||
String.format("%02d", get(TimeUnit.HOUR)),
|
||||
COLON,
|
||||
get(TimeUnit.MINUTE),
|
||||
String.format("%02d", get(TimeUnit.MINUTE)),
|
||||
COLON,
|
||||
get(TimeUnit.SECOND),
|
||||
COLON,
|
||||
get(TimeUnit.MILLISECOND));
|
||||
String.format("%02d", get(TimeUnit.SECOND)),
|
||||
DOT,
|
||||
String.format("%03d", get(TimeUnit.MILLISECOND)));
|
||||
}
|
||||
|
||||
public String toHumanString() {
|
||||
long days = get(TimeUnit.DAY);
|
||||
long hours = get(TimeUnit.HOUR);
|
||||
long minutes = get(TimeUnit.MINUTE);
|
||||
long seconds = get(TimeUnit.SECOND);
|
||||
long milliseconds = get(TimeUnit.MILLISECOND);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!this.isPositive()) {
|
||||
sb.append(MINUS).append(" ");
|
||||
}
|
||||
if (days > 0) {
|
||||
sb.append(days).append(" ").append(TimeUnit.DAY.name().toLowerCase()).append((days > 1) ? "s" : "").append(" ");
|
||||
}
|
||||
if (hours > 0) {
|
||||
sb.append(hours).append(" ").append(TimeUnit.HOUR.name().toLowerCase()).append((hours > 1) ? "s" : "").append(" ");
|
||||
}
|
||||
if (minutes > 0) {
|
||||
sb.append(minutes).append(" ").append(TimeUnit.MINUTE.name().toLowerCase()).append((minutes > 1) ? "s" : "").append(" ");
|
||||
}
|
||||
sb.append(seconds).append(" ").append(TimeUnit.SECOND.name().toLowerCase()).append((seconds > 1) ? "s" : "");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
@ -54,7 +54,8 @@ class RemainingTimeCalculator {
|
||||
|
||||
public long remainingSecondsUntilEnd() {
|
||||
long remains = this.total - this.done;
|
||||
long remainsSeconds = (this.elapsedSecondSinceStart() / this.done) * remains;
|
||||
double elapsedSecondSinceStartDouble = (double) elapsedSecondSinceStart();
|
||||
long remainsSeconds = (long)((elapsedSecondSinceStartDouble / ((double)this.done)) * remains);
|
||||
return remainsSeconds;
|
||||
}
|
||||
|
||||
@ -63,6 +64,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.";
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-utils</artifactId>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-view</artifactId>
|
||||
@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-web</artifactId>
|
||||
@ -51,7 +51,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -61,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.12.1</version>
|
||||
<version>${jsoup.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<parent>
|
||||
<groupId>org.nanoboot.powerframework</groupId>
|
||||
<artifactId>power-framework</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>power-xml</artifactId>
|
||||
@ -51,7 +51,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>${junit4.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
Reference in New Issue
Block a user