Skip to content

Commit 8d5bc1f

Browse files
committed
1.36
1 parent 03f0f99 commit 8d5bc1f

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package dev.felnull.fnjl;
22

33
public class FNJLBuildIn {
4-
protected static final String VERSION = "1.35";
4+
protected static final String VERSION = "1.36";
55
}

common/src/main/java/dev/felnull/fnjl/util/FNStringUtil.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,41 @@ public static String getPercentage(float par) {
214214
public static UUID fromNoHyphenStringToUUID(String uuidStr) {
215215
return UUID.fromString(uuidStr.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
216216
}
217+
218+
/**
219+
* 時間をhh:mm:ss/hh:mm:ssのような進捗度で出力する
220+
*
221+
* @param compTime 経過時間
222+
* @param totalTime 合計時間
223+
* @return フォーマット済み文字列
224+
*/
225+
public static String getTimeProgress(long compTime, long totalTime) {
226+
return getTimeFormat(compTime, totalTime >= 3600000) + "/" + getTimeFormat(totalTime);
227+
}
228+
229+
/**
230+
* 時間をhh:mm:ssのように出力する
231+
*
232+
* @param time 時間
233+
* @return フォーマット済み文字列
234+
*/
235+
public static String getTimeFormat(long time) {
236+
return getTimeFormat(time, false);
237+
}
238+
239+
/**
240+
* 時間をhh:mm:ssのように出力する
241+
*
242+
* @param time 時間
243+
* @param hour 時の表示を強制するか
244+
* @return フォーマット済み文字列
245+
*/
246+
public static String getTimeFormat(long time, boolean hour) {
247+
long hourTime = time / 3600000;
248+
long minTime = (time - hourTime * 3600000) / 60000;
249+
long secTime = (time - hourTime * 3600000 - minTime * 60000) / 1000;
250+
if (hourTime > 0 || hour)
251+
return String.format("%02d:%02d:%02d", hourTime, minTime, secTime);
252+
return String.format("%02d:%02d", minTime, secTime);
253+
}
217254
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package dev.felnull.fnjltest;
22

3+
import dev.felnull.fnjl.util.FNStringUtil;
4+
35
public class Main {
46
public static void main(String[] args) {
5-
7+
System.out.println(FNStringUtil.getTimeProgress(1919, 11451419));
8+
//System.out.println(FNStringUtil.getTimeFormat(1000 * 60 * 125 + 5000));
69
}
710
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fnjl_group=dev.felnull
22
fnjl_name=felnull-java-library
3-
fnjl_version=1.35
3+
fnjl_version=1.36
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.felnull.fnjln;
22

33
public class FNJLNBuildIn {
4-
protected static final String VERSION = "1.35";
4+
protected static final String VERSION = "1.36";
55

66
protected static final int NATIVE_LIBRARY_VERSION = 1;
77
}

0 commit comments

Comments
 (0)