Java Date String Format formatDate(byte[] btValue, int iOffset, int iLength)

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

Description

format Date

License

Apache License

Declaration

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

Method Source Code

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

public class Main {
    public static String formatDate(byte[] btValue, int iOffset, int iLength) {
        if ((btValue.length < iOffset + iLength) || (iLength < 4))
            return "";
        return getBCDString(btValue[iOffset + 3]) + "/"
                + getBCDString(btValue[iOffset + 2]) + "/"
                + getBCDString(btValue[iOffset + 0])
                + getBCDString(btValue[iOffset + 1]);
    }//www.j  av  a 2 s .co  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. dateFormat(String date)
  2. dateFormat(String datetime)
  3. dateFormat(String strYear, String strMonth, String strDay)
  4. dateFormatFix(String str)
  5. formatDate(int year, int month, int day)
  6. formatDate(Integer date)
  7. formatDate(Integer day, Integer month, Integer year)
  8. FormatDate(String aDate)