xiangpei
2024-03-28 0f431b52e0936456bd165d9553761bfd8a5a0517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.mindskip.xzs.utility;
 
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @version 2.2.0
 * @description: 考试工具
 * Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
 * @date 2021/9/7 9:45
 */
public class ExamUtil {
 
    /**
     * 千分制转换
     *
     * @param score the score
     * @return the string
     */
    public static String scoreToVM(Integer score) {
        if (score % 10 == 0) {
            return String.valueOf(score / 10);
        } else {
            return String.format("%.1f", score / 10.0);
        }
    }
 
    /**
     * 千分制转换
     *
     * @param score the score
     * @return the integer
     */
    public static Integer scoreFromVM(String score) {
        if (score == null) {
            return null;
        } else {
            return (int) (Float.parseFloat(score) * 10);
        }
    }
 
    /**
     * 秒转换
     *
     * @param second the second
     * @return the string
     */
    public static String secondToVM(Integer second) {
        String dateTimes;
        long days = second / (60 * 60 * 24);
        long hours = (second % (60 * 60 * 24)) / (60 * 60);
        long minutes = (second % (60 * 60)) / 60;
        long seconds = second % 60;
        if (days > 0) {
            dateTimes = days + "天 " + hours + "时 " + minutes + "分 " + seconds + "秒";
        } else if (hours > 0) {
            dateTimes = hours + "时 " + minutes + "分 " + seconds + "秒";
        } else if (minutes > 0) {
            dateTimes = minutes + "分 " + seconds + "秒";
        } else {
            dateTimes = seconds + " 秒";
        }
        return dateTimes;
    }
 
    private static final String ANSWER_SPLIT = ",";
 
    /**
     * Content to string string.
     *
     * @param contentArray the content array
     * @return the string
     */
    public static String contentToString(List<String> contentArray) {
        return contentArray.stream().sorted().collect(Collectors.joining(ANSWER_SPLIT));
    }
 
 
    /**
     * Content to array list.
     *
     * @param contentArray the content array
     * @return the list
     */
    public static List<String> contentToArray(String contentArray) {
        return Arrays.asList(contentArray.split(ANSWER_SPLIT));
    }
 
    private static final String FORM_ANSWER_SPLIT = "_";
 
    /**
     * Last num integer.
     *
     * @param str the str
     * @return the integer
     */
    public static Integer lastNum(String str) {
        Integer start = str.lastIndexOf(FORM_ANSWER_SPLIT);
        return Integer.parseInt(str.substring(start + 1));
    }
}