Joda を使用して段階的に:
計算に使用されたデータは、あなたが参照したウェブサイトで見つけることができます。
// we start with your string minus the three last digits
// which are some internal z/Series cruft
BigInteger bi = new BigInteger ("CAE7631DC43DC", 16); // 686 stripped off
// then, from tables the website we get the TOD value for start of epoch
// here also, minus the three last digits
BigInteger startOfEpoch70 = new BigInteger ("7D91048BCA000", 16); // 000 stripped off
// using that we calculate the offset in microseconds in epoch
BigInteger microsinepoch = bi.subtract(startOfEpoch70);
// and reduce to millis
BigInteger millisinepoch = microsinepoch.divide(new BigInteger("1000"));
// which we convert to a long to feed to Joda
long millisinepochLong = millisinepoch.longValue();
// Et voila, the result in UTC
DateTime result = new DateTime(millisinepochLong).withZone(DateTimeZone.UTC);
// Now, if you want a result in some other timezone, that's equally easy
// with Joda:
DateTime result2 = result.toDateTime(DateTimeZone.forID("EET"));
System.out.println("The result is " + result + " or represented in timezone EET "
+ result2);
次の出力が得られます。
結果は 2013-02-10T21:59:46.420Z またはタイムゾーン EET 2013-02-10T23:59:46.420+02:00 で表されます
私が言及する「クラフト」は、次のように説明されています。
最後の 12 ビットはスキップします (通常、これらのビットの一部は、TOD クロックの読み取りにどのプロセッサーが使用され、どの LPAR がアクティブであったかを知るために MVS によって使用されます)。
もちろん、これらのバイトを文字列から残酷に切り取る代わりに、次のこともできます。
bi = bi.divide(new BigInteger("1000", 16));
16 進数の 1000 で割ると、最後の 12 ビットも取り除かれます。
編集: Mehmet がコメントで指摘したように、TOD は UTC であり、これは、結果の DateTime がそのように伝えられる必要があることを意味します。便宜上、その DateTime を別のタイム ゾーンに転置する方法も示しましEET
た (例として使用)。