whyclj
2019-07-24 c9f8b9e09489e547734246140b4fd3635100fbb6
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
package com.fbs9100;
 
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
 
public class FBS_TestTime
{
    public int hour = 0;
    public int minute = 0;
    public int second = 0;
 
    public void putByteBuffer(final ByteBuffer bf)
    {
        hour = FBS_ComBase.changeByteToInt(bf.get());
        minute = FBS_ComBase.changeByteToInt(bf.get());
        second = FBS_ComBase.changeByteToInt(bf.get());
    }
 
    public ByteBuffer getBytes()
    {
        ByteBuffer bytebuffer = ByteBuffer.allocate(6);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.put(FBS_ComBase.changeIntToByte(hour));
        bytebuffer.put(FBS_ComBase.changeIntToByte(minute));
        bytebuffer.put(FBS_ComBase.changeIntToByte(second));
        bytebuffer.flip();
 
        return bytebuffer;
    }
 
    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;
    }
}
/***************************************************************************************
 ****************************** end of file (FBS_TestTime) ******************************
 ***************************************************************************************/