package com.whyc.bts;
|
|
import com.whyc.util.ComBase;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
|
|
public class BTS_TestTime
|
{
|
public int hour = 0;
|
public int minute = 0;
|
public int second = 0;
|
|
public String testTime; //时分秒
|
|
public void putByteBuffer(final ByteBuffer bf)
|
{
|
hour = BTS_ComBase.changeByteToInt(bf.get());
|
minute = BTS_ComBase.changeByteToInt(bf.get());
|
second = BTS_ComBase.changeByteToInt(bf.get());
|
this.testTime="";
|
if(this.hour<10){
|
this.testTime=this.testTime+"0"+this.hour;
|
}else {
|
this.testTime=this.testTime+this.hour;
|
}
|
if(this.minute<10){
|
this.testTime=this.testTime+":"+"0"+this.minute;
|
}else {
|
this.testTime=this.testTime+":"+this.minute;
|
}
|
if(this.second<10){
|
this.testTime=this.testTime+":"+"0"+this.second;
|
}else {
|
this.testTime=this.testTime+":"+this.second;
|
}
|
//System.out.println("this.testTime:"+this.testTime);
|
}
|
|
public BTS_TestTime clone(){
|
BTS_TestTime bts_test = new BTS_TestTime();
|
bts_test.hour = hour;
|
bts_test.minute = minute;
|
bts_test.second = second;
|
|
bts_test.testTime = testTime; //时分秒
|
|
return bts_test;
|
}
|
|
public ByteBuffer getBytes()
|
{
|
ByteBuffer bytebuffer = ByteBuffer.allocate(6);
|
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
bytebuffer.put(BTS_ComBase.changeIntToByte(hour));
|
bytebuffer.put(BTS_ComBase.changeIntToByte(minute));
|
bytebuffer.put(BTS_ComBase.changeIntToByte(second));
|
bytebuffer.flip();
|
|
return bytebuffer;
|
}
|
|
public int getSecondCount()
|
{
|
return (hour*3600 + minute*60 + second);
|
}
|
|
public static int getMinutesCount(String str)
|
{
|
int mcount = 0;
|
try
|
{
|
// 先找到字符串中:的位置
|
int position = str.indexOf(":");
|
// 将每个:之间的字符串转换成整型
|
mcount = Integer.parseInt(str.substring(0, position))*60;
|
mcount += Integer.parseInt(str.substring(position + 1));
|
}
|
catch(Exception e)
|
{
|
mcount = 0;
|
}
|
|
return mcount;
|
}
|
|
@Override
|
public String toString() {
|
return "FBS9100_TestTime [hour=" + hour + ", minute=" + minute + ", second=" + second + "]";
|
}
|
|
|
}
|