-1

我想将 Windows:128 位系统结构,即..,“D9070B00010002000600090013000000”转换为人类可读的格式,即..,星期一,2009 年 11 月 2 日 06:09:19,所以有算法可以转换它,我没有得到。供参考http://www.digital-detective.co.uk/freetools/decode.asp其中示例时间和 java 中的转换时间。

提前致谢

4

1 回答 1

0

您包含的格式是某种小端十六进制编码的单词混乱。看起来非常低效。

但是,它可以这样解码:

long getSystemStructureTime(String enc) {
    long result = -1L;
    // system time is typically a set of WORDs encoded, little-endian
    if (!TextUtils.isEmpty(enc)) {
        final int length = enc.length();
        ByteBuffer b = ByteBuffer.allocate(length / 2);
        b.order(ByteOrder.BIG_ENDIAN);
        for (int i = 0; i < enc.length(); i+=2) {
            b.put((byte) Integer.parseInt(enc.substring(i, i + 2), 16));
        }
        b.flip();
        b.order(ByteOrder.LITTLE_ENDIAN);
        try {
            int year = b.getShort();
            int month = b.getShort();
            int day = b.getShort();
            int dayOfMonth = b.getShort();
            int hourOfDay = b.getShort();
            int minuteOfHour = b.getShort();
            int secondsOfMinute = b.getShort();
            int millisOfSecond = b.getShort();

            Calendar c = Calendar.getInstance();
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, month - 1); // months in calendar are base 0
            c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            c.set(Calendar.HOUR_OF_DAY, hourOfDay);
            c.set(Calendar.MINUTE, minuteOfHour);
            c.set(Calendar.SECOND, secondsOfMinute);
            c.set(Calendar.MILLISECOND, millisOfSecond);

            result = c.getTimeInMillis();
        } catch (BufferUnderflowException e) {
            // This wasn't a proper time..
        }
    }
    return result;
}

塞进你发布的内容:

System.out.println(new Date(getSystemStructureTime("D9070B00010002000600090013000000")));

产量:

Mon Nov 02 06:09:19 GMT+00:00 2009

Calendar此版本以毫秒为单位返回时间,根据您的喜好,返回解析期间创建的实例可能会更好。

于 2012-05-08T13:11:00.007 回答