DELL
2024-09-24 a01db2b59f0de8dfa4fb029d86d45924f4534abc
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
package com.whyc.mcp;
 
import com.whyc.util.ComBase;
 
import java.nio.ByteBuffer;
import java.util.Calendar;
import java.util.Date;
 
public class DateTime {
    private static final int BYTE_LEN = 6;
    public int year;
    public int month;
    public int day;
    public int hour;
    public int minute;
    public int second;
 
    public Date time;
 
    public DateTime() {
    }
 
    public void setDateTime(ByteBuffer bf) {
        if(bf.remaining()< BYTE_LEN) {
            return;
        }
        this.year = ComBase.changeByteToInt(bf.get());
        this.month = ComBase.changeByteToInt(bf.get());
        this.day = ComBase.changeByteToInt(bf.get());
        this.hour = ComBase.changeByteToInt(bf.get());
        this.minute = ComBase.changeByteToInt(bf.get());
        this.second = ComBase.changeByteToInt(bf.get());
 
        time = getFBODateTime();
    }
 
    public Date getFBODateTime() {
        Calendar c = Calendar.getInstance();
        c.set(2000+year, month, day, hour, minute, second);
        return c.getTime();
    }
}