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();
|
}
|
}
|