/** * Get the DateTimeValue corresponding to a given Julian instant * * @param instant the Julian instant: a decimal value whose integer part is the Julian day number * multiplied by the number of seconds per day, and whose fractional part is the fraction of * the second. * @return the xs:dateTime value corresponding to the Julian instant. This will always be in * timezone Z. */ public static DateTimeValue fromJulianInstant(BigDecimal instant) { BigInteger julianSecond = instant.toBigInteger(); BigDecimal microseconds = instant .subtract(new BigDecimal(julianSecond)) .multiply(DecimalValue.BIG_DECIMAL_ONE_MILLION); long js = julianSecond.longValue(); long jd = js / (24L * 60L * 60L); DateValue date = DateValue.dateFromJulianDayNumber((int) jd); js = js % (24L * 60L * 60L); byte hour = (byte) (js / (60L * 60L)); js = js % (60L * 60L); byte minute = (byte) (js / (60L)); js = js % (60L); return new DateTimeValue( date.getYear(), date.getMonth(), date.getDay(), hour, minute, (byte) js, microseconds.intValue(), 0); }