package com.dev.fbs9009;
|
|
import java.nio.ByteBuffer;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.base.ComBase;
|
|
public class LD_date_time {
|
public static int BYTE_LEN=3; //¼Ä´æÆ÷¸öÊý
|
private int cmd; //·¢ËÍÊý¾ÝµÄÃüÁî
|
private int cmd_addr; //Ä£¿éµØÖ·(»ò·¢ËÍʱµÄ¼Ä´æÆ÷µÄÆðʼµØÖ·)
|
private int cmd_addr_back; //½ÓÊռĴæÆ÷µÄÆðʼµØÖ·
|
private int dataCount; //Êý¾ÝµÄ³¤¶È
|
private int year;
|
private int month;
|
private int day;
|
private int hour;
|
private int minute;
|
private int second;
|
|
|
|
//»ñȡϵͳʱ¼ä
|
public boolean setLD_param(ByteBuffer bf){
|
boolean flag = false;
|
ByteBuffer tmpbuf = bf;
|
tmpbuf.position(0);
|
try {
|
this.cmd_addr = ComBase.changeByteToInt(tmpbuf.get());
|
this.cmd = ComBase.changeByteToInt(tmpbuf.get()); //ÃüÁîµØÖ·
|
this.cmd_addr_back = ComBase.changeShortToInt(tmpbuf.getShort());
|
this.dataCount = ComBase.changeByteToInt(tmpbuf.get());
|
|
System.out.println("Êý¾ÝÇø×Ö½ÚÊýµÄ³¤¶È:"+this.dataCount);
|
int Y_M=tmpbuf.getShort();
|
this.year=Y_M&0xFF00;
|
this.month=Y_M&0x00FF;
|
|
int D_H=tmpbuf.getShort();
|
this.day=D_H&0xFF00;
|
this.hour=D_H&0x00FF;
|
|
int M_S=tmpbuf.getShort();
|
this.minute=M_S&0xFF00;
|
this.second=M_S&0x00FF;
|
|
flag = true;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return flag;
|
}
|
|
/**
|
* ¸ñʽ»¯Ê±¼ä
|
* @return
|
*/
|
public String formartDate(){
|
return this.year+"-"+this.month+"-"+this.day+" "+this.hour+":"+this.minute+":"+second;
|
}
|
|
/**
|
* »ñÈ¡µ±Ç°Ï̵߳Äʱ¼ä
|
* @return
|
*/
|
public Date getNowTime(){
|
String datestr = formartDate();
|
Date time = Com.getDateTimeFromStr(datestr, Com.DTF_YMDhms);
|
return time;
|
}
|
|
|
public int getCmd() {
|
return cmd;
|
}
|
|
public void setCmd(int cmd) {
|
this.cmd = cmd;
|
}
|
|
public int getCmd_addr() {
|
return cmd_addr;
|
}
|
|
public void setCmd_addr(int cmd_addr) {
|
this.cmd_addr = cmd_addr;
|
}
|
|
public int getDataCount() {
|
return dataCount;
|
}
|
|
public void setDataCount(int dataCount) {
|
this.dataCount = dataCount;
|
}
|
|
public int getYear() {
|
return year;
|
}
|
|
public void setYear(int year) {
|
this.year = year;
|
}
|
|
public int getMonth() {
|
return month;
|
}
|
|
public void setMonth(int month) {
|
this.month = month;
|
}
|
|
public int getDay() {
|
return day;
|
}
|
|
public void setDay(int day) {
|
this.day = day;
|
}
|
|
public int getHour() {
|
return hour;
|
}
|
|
public void setHour(int hour) {
|
this.hour = hour;
|
}
|
|
public int getMinute() {
|
return minute;
|
}
|
|
public void setMinute(int minute) {
|
this.minute = minute;
|
}
|
|
public int getSecond() {
|
return second;
|
}
|
|
public void setSecond(int second) {
|
this.second = second;
|
}
|
|
@Override
|
public String toString() {
|
return "LD_date_time [cmd=" + cmd + ", cmd_addr=" + cmd_addr + ", dataCount=" + dataCount + ", year=" + year
|
+ ", month=" + month + ", day=" + day + ", hour=" + hour + ", minute=" + minute + ", second=" + second
|
+ "]";
|
}
|
|
|
}
|