cjl
19 hours ago 256aa4c5431733e5d166f583f03724cf69ddfaa4
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
package com.moral.api.util;
 
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class Method {
 
    public static Map<String, Object> getDataStore(String data) {
        data = data.replaceFirst("&&",";");
        Map<String, Object> dataStore = new HashMap<>();
        String[] commands = data.split(";");
        List<String> commandList = Arrays.asList(commands);
        commandList.forEach(command -> {
            String[] cmds = command.split("=");
            String key = cmds[0];
            String value = cmds.length > 1 ? cmds[1] : "";
            dataStore.put(key, value);
        });
        return dataStore;
    }
 
    public static Map<String, Object> getCpDataStore(String cp) {
        String[] dataItems = cp.split(";"); // [array]
        Map<String, Object> dataStore = new HashMap<>();
        List<String> dataItemList = Arrays.asList(dataItems);
        dataItemList.forEach(dataItem -> {
            String[] itemArr= dataItem.split(";");
            List<String> itemList = Arrays.asList(itemArr);
            itemList.forEach(item -> {
                String[] item1Arr = item.split(",");
                List<String> item1List = Arrays.asList(item1Arr);
                item1List.forEach(itemChild -> {
                    String[] items = itemChild.split("=");
                    String item1 = items[0];
                    String item2 = items[1];
                    if(item1.endsWith("-Rtd")) {
                        String key = item1.replace("-Rtd", "");
                        dataStore.put(key, item2);
                    }else{
                        String k = item1;
                        dataStore.put(k, item2);
                    }
                });
            });
        });
        return dataStore;
    }
 
    public static long getTimeStamp(String time, String format) {
 
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (!"".equals(format)) {
            simpleDateFormat = new SimpleDateFormat(format);
        }
 
        long timeStemp = 0;
        try {
 
            Date date = simpleDateFormat.parse(time);
 
            timeStemp = date.getTime();
 
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return timeStemp;
    }
}