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
package com.netsdk.lib.structure;
 
import com.netsdk.lib.NetSDKLib;
 
import java.util.Calendar;
import java.util.Date;
 
/**
 * 时间
 *
 * @author 47081
 */
public class NET_TIME extends NetSDKLib.SdkStructure {
  /** 年 */
  public int dwYear;
  /** 月 */
  public int dwMonth;
  /** 日 */
  public int dwDay;
  /** 时 */
  public int dwHour;
  /** 分 */
  public int dwMinute;
  /** 秒 */
  public int dwSecond;
 
  public NET_TIME() {
    super();
  }
 
  public NET_TIME(int dwYear, int dwMonth, int dwDay, int dwHour, int dwMinute, int dwSecond) {
    this.dwYear = dwYear;
    this.dwMonth = dwMonth;
    this.dwDay = dwDay;
    this.dwHour = dwHour;
    this.dwMinute = dwMinute;
    this.dwSecond = dwSecond;
  }
 
  /**
   * 字符串解析时间
   *
   * @param date 时间字符串,举例2020/5/20/12/20/34
   */
  public NET_TIME(String date) {
    String[] dates = date.split("/");
    this.dwYear = Integer.parseInt(dates[0]);
    this.dwMonth = Integer.parseInt(dates[1]);
    this.dwDay = Integer.parseInt(dates[2]);
    this.dwHour = Integer.parseInt(dates[3]);
    this.dwMinute = Integer.parseInt(dates[4]);
    this.dwSecond = Integer.parseInt(dates[5]);
  }
 
  // 用于列表中显示
  public String toStringTime() {
    return String.format(
        "%02d/%02d/%02d %02d:%02d:%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
  }
 
  public String toStringTimeEx() {
    return String.format(
        "%02d-%02d-%02d %02d:%02d:%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
  }
 
  public String toString() {
    return String.format(
        "%02d%02d%02d%02d%02d%02d", dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
  }
 
  public Date toDate() {
    Calendar instance = Calendar.getInstance();
    instance.set(this.dwYear, this.dwMonth, this.dwDay, this.dwHour, this.dwMinute, this.dwSecond);
    return instance.getTime();
  }
}