Here you can find the source of formatTimeStamp(byte[] btValue, int iOffset, int iLength, int iUtcOffset)
public static String formatTimeStamp(byte[] btValue, int iOffset, int iLength, int iUtcOffset)
//package com.java2s; //License from project: Apache License import java.util.*; import java.text.*; public class Main { public static SimpleDateFormat fmtDateTime = new SimpleDateFormat( "dd/MM/yy HH:mm:ss"); public static String formatTimeStamp(byte[] btValue, int iOffset, int iLength, int iUtcOffset) { if ((btValue.length < iOffset + iLength) || (iLength < 9)) return ""; Date dtReturn = null;/*from w w w .j a v a 2 s. co m*/ long lOffset = 0; if (btValue[iOffset + 2] == '+' || btValue[iOffset + 2] == '-') { dtReturn = new Date(getBCDValue(btValue[iOffset + 8]), getBCDValue(btValue[iOffset + 7]) - 1, getBCDValue(btValue[iOffset + 6]), getBCDValue(btValue[iOffset + 5]), getBCDValue(btValue[iOffset + 4]), getBCDValue(btValue[iOffset + 3])); lOffset = getBCDValue(btValue[iOffset + 1]) * 3600; lOffset += getBCDValue(btValue[iOffset]) * 60; lOffset *= 1000; if (btValue[iOffset + 2] == '-') lOffset = -lOffset; dtReturn.setTime(dtReturn.getTime() - lOffset + iUtcOffset); return fmtDateTime.format(dtReturn); } dtReturn = new Date(getBCDValue(btValue[iOffset]), getBCDValue(btValue[iOffset + 1]) - 1, getBCDValue(btValue[iOffset + 2]), getBCDValue(btValue[iOffset + 3]), getBCDValue(btValue[iOffset + 4]), getBCDValue(btValue[iOffset + 5])); lOffset = getBCDValue(btValue[iOffset + 7]) * 3600; lOffset += getBCDValue(btValue[iOffset + 8]) * 60; lOffset *= 1000; if (btValue[iOffset + 6] == '-') lOffset = -lOffset; dtReturn.setTime(dtReturn.getTime() - lOffset + iUtcOffset); return fmtDateTime.format(dtReturn); } public static int getBCDValue(byte btValue) { int iReturn; iReturn = ((btValue & 0xF0) >>> 4) * 10; iReturn += ((btValue & 0x0F)); return iReturn; } }