Java Time Format formatTime(byte[] btValue, int iOffset, int iLength)

Here you can find the source of formatTime(byte[] btValue, int iOffset, int iLength)

Description

format Time

License

Apache License

Declaration

public static String formatTime(byte[] btValue, int iOffset, int iLength) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String formatTime(byte[] btValue, int iOffset, int iLength) {
        if ((btValue.length < iOffset + iLength) || (iLength < 3))
            return "";
        return getBCDString(btValue[iOffset + 0]) + ":"
                + getBCDString(btValue[iOffset + 1]) + ":"
                + getBCDString(btValue[iOffset + 2]);
    }//from w  w w .  ja  va  2 s. c  o m

    public static String getBCDString(byte btValue) {
        byte l, h;
        h = (byte) ((btValue & 0xF0) >>> 4);
        if (h < 10)
            h = (byte) ('0' + h);
        else
            h = (byte) ('A' + h - 10);

        l = (byte) ((btValue & 0x0F));
        if (l < 10)
            l = (byte) ('0' + l);
        else
            l = (byte) ('A' + l - 10);

        return String.valueOf((char) h) + String.valueOf((char) l);
    }
}

Related

  1. formatStartRowKeyString(String id, String timestampStart)
  2. formatStrDateTime(String stringDateTime)
  3. formatString(String agentId, long agentStartTime, long transactionSequence)
  4. formattedStats(String pExecTime, int pTxns)
  5. formattedUnixTime()
  6. formatTime(double time)
  7. formatTime(double totalTime)
  8. formatTime(final int timeSec)
  9. formatTime(final long time)