Here you can find the source of toASCIICode(byte[] bts)
public static byte[] toASCIICode(byte[] bts)
//package com.java2s; public class Main { public static byte[] toASCIICode(byte[] bts) { byte[] format_str = new byte[128]; int btsLength = bts.length; int year = btsLength > 1 ? bts[0] * 256 + 256 + bts[1] : 1900; int month = btsLength > 2 ? bts[2] : 1; int day = btsLength > 3 ? bts[3] : 1; int hour = btsLength > 4 ? bts[4] : 0; int minute = btsLength > 5 ? bts[5] : 0; int second = btsLength > 6 ? bts[6] : 0; int index = 3; int temp = year; for (; index >= 0; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10;/* w ww .j a v a 2 s. c o m*/ } format_str[4] = '-'; index = 6; temp = month; for (; index >= 5; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10; } format_str[7] = '-'; index = 9; temp = day; for (; index >= 8; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10; } format_str[10] = ','; index = 12; temp = hour; for (; index >= 11; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10; } format_str[13] = ':'; index = 15; temp = minute; for (; index >= 14; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10; } format_str[16] = ':'; index = 18; temp = second; for (; index >= 17; index--) { format_str[index] = (byte) (48 + (temp - temp / 10 * 10)); temp /= 10; } return format_str; } }