Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 5b23d24

Browse files
committed
修改不符合P3C规约的代码
1 parent 12c9ea6 commit 5b23d24

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/main/java/com/zhazhapan/qiniu/controller/MainWindowController.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ private void initialize() {
196196
resTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
197197
// 设置默认的开始和结束日期,并调用dateChange事件刷新数据
198198
endDate.setValue(LocalDate.now());
199-
LocalDate endDate = Utils.dateToLocalDate(new Date(new Date().getTime() - Values.DATE_SPAN_OF_THIRTY_ONE));
199+
long startTime = System.currentTimeMillis() - Values.DATE_SPAN_OF_THIRTY_ONE;
200+
LocalDate endDate = Utils.dateToLocalDate(new Date(startTime));
200201
startDate.setValue(endDate);
201202
// 设置BucketChoiceComboBox改变事件,改变后并配置新的上传环境
202203
bucketChoiceCombo.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {

src/main/java/com/zhazhapan/qiniu/util/Formatter.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ public class Formatter {
2828

2929
private static Logger logger = Logger.getLogger(Formatter.class);
3030

31-
private static final String[] SIZE_POST = { "TB", "GB", "MB", "KB" };
31+
private static final String SIZE_KB = "KB";
32+
33+
private static final String SIZE_MB = "MB";
34+
35+
private static final String SIZE_GB = "GB";
36+
37+
private static final String SIZE_TB = "TB";
3238

3339
public static int stringToInt(String string) {
3440
if (Checker.isNumber(string)) {
@@ -65,13 +71,13 @@ public static long sizeToLong(String size) {
6571
if (Checker.isNotEmpty(size)) {
6672
String num = size.split(" ")[0];
6773
double result = 0;
68-
if (size.contains(SIZE_POST[0])) {
74+
if (size.contains(SIZE_TB)) {
6975
result = stringToDouble(num) * Values.TB;
70-
} else if (size.contains(SIZE_POST[1])) {
76+
} else if (size.contains(SIZE_GB)) {
7177
result = stringToDouble(num) * Values.GB;
72-
} else if (size.contains(SIZE_POST[2])) {
78+
} else if (size.contains(SIZE_MB)) {
7379
result = stringToDouble(num) * Values.MB;
74-
} else if (size.contains(SIZE_POST[3])) {
80+
} else if (size.contains(SIZE_KB)) {
7581
result = stringToDouble(num) * Values.KB;
7682
} else {
7783
result = stringToDouble(num);

src/main/java/com/zhazhapan/qiniu/view/MainWindow.java

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public void init() {
5555
Dialogs.showFatalError(Values.INIT_APP_ERROR_HEADER, e);
5656
}
5757
stage.setTitle(Values.MAIN_TITLE);
58-
// stage.setResizable(false);
5958
stage.setOnCloseRequest((e) -> {
6059
ThreadPool.shutdown();
6160
ConfigLoader.checkWorkPath();

src/test/java/com/zhazhapan/qiniu/TestFormatter.java renamed to src/test/java/com/zhazhapan/qiniu/FormatterTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @author pantao
1212
*
1313
*/
14-
public class TestFormatter {
14+
public class FormatterTest {
1515

1616
@Test
1717
public void testSizeToLong() {

0 commit comments

Comments
 (0)