@Test
  public void testJulianDay() {
    //check if May 23, 1968 is Julian Day 2440000
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    cal.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
    cal.set(Calendar.YEAR,  1968);
    cal.set(Calendar.MONTH, Calendar.MAY);
    cal.set(Calendar.DAY_OF_MONTH, 23);
    cal.set(Calendar.HOUR_OF_DAY, 0);

    Timestamp ts = Timestamp.ofEpochMilli(cal.getTimeInMillis());
    NanoTime nt = NanoTimeUtils.getNanoTime(ts, TimeZone.getDefault().toZoneId() ,false);
    Assert.assertEquals(nt.getJulianDay(), 2440000);

    Timestamp tsFetched = NanoTimeUtils.getTimestamp(nt, TimeZone.getDefault().toZoneId());
    Assert.assertEquals(tsFetched, ts);

    //check if 30 Julian Days between Jan 1, 2005 and Jan 31, 2005.
    GregorianCalendar cal1 = new GregorianCalendar();
    cal1.setTimeZone(TimeZone.getTimeZone("GMT"));
    cal1.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
    cal1.set(Calendar.YEAR,  2005);
    cal1.set(Calendar.MONTH, Calendar.JANUARY);
    cal1.set(Calendar.DAY_OF_MONTH, 1);
    cal1.set(Calendar.HOUR_OF_DAY, 0);

    Timestamp ts1 = Timestamp.ofEpochMilli(cal1.getTimeInMillis());
    NanoTime nt1 = NanoTimeUtils.getNanoTime(ts1, TimeZone.getDefault().toZoneId() ,false);

    Timestamp ts1Fetched = NanoTimeUtils.getTimestamp(nt1, TimeZone.getDefault().toZoneId());
    Assert.assertEquals(ts1Fetched, ts1);

    GregorianCalendar cal2 = new GregorianCalendar();
    cal2.setTimeZone(TimeZone.getTimeZone("UTC"));
    cal2.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
    cal2.set(Calendar.YEAR,  2005);
    cal2.set(Calendar.MONTH, Calendar.JANUARY);
    cal2.set(Calendar.DAY_OF_MONTH, 31);
    cal2.set(Calendar.HOUR_OF_DAY, 0);

    Timestamp ts2 = Timestamp.ofEpochMilli(cal2.getTimeInMillis());
    NanoTime nt2 = NanoTimeUtils.getNanoTime(ts2, TimeZone.getDefault().toZoneId(), false);

    Timestamp ts2Fetched = NanoTimeUtils.getTimestamp(nt2, TimeZone.getDefault().toZoneId());
    Assert.assertEquals(ts2Fetched, ts2);
    Assert.assertEquals(nt2.getJulianDay() - nt1.getJulianDay(), 30);

    // check if 730517 Julian Days between Jan 1, 0005 and Jan 31, 2005.
    // This method used to test Julian Days between Jan 1, 2005 BCE and Jan 1, 2005 CE. Since BCE
    // timestamps are not supported, both dates were changed to CE.
    cal1 = new GregorianCalendar();
    cal1.setTimeZone(TimeZone.getTimeZone("GMT"));
    cal1.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
    cal1.set(Calendar.YEAR,  0005);
    cal1.set(Calendar.MONTH, Calendar.JANUARY);
    cal1.set(Calendar.DAY_OF_MONTH, 1);
    cal1.set(Calendar.HOUR_OF_DAY, 0);

    ts1 = Timestamp.ofEpochMilli(cal1.getTimeInMillis());
    nt1 = NanoTimeUtils.getNanoTime(ts1, TimeZone.getDefault().toZoneId(), false);

    ts1Fetched = NanoTimeUtils.getTimestamp(nt1, TimeZone.getDefault().toZoneId());
    Assert.assertEquals(ts1Fetched, ts1);

    cal2 = new GregorianCalendar();
    cal2.setTimeZone(TimeZone.getTimeZone("UTC"));
    cal2.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
    cal2.set(Calendar.YEAR,  2005);
    cal2.set(Calendar.MONTH, Calendar.JANUARY);
    cal2.set(Calendar.DAY_OF_MONTH, 31);
    cal2.set(Calendar.HOUR_OF_DAY, 0);

    ts2 = Timestamp.ofEpochMilli(cal2.getTimeInMillis());
    nt2 = NanoTimeUtils.getNanoTime(ts2, TimeZone.getDefault().toZoneId(), false);

    ts2Fetched = NanoTimeUtils.getTimestamp(nt2, TimeZone.getDefault().toZoneId());
    Assert.assertEquals(ts2Fetched, ts2);
    Assert.assertEquals(730517, nt2.getJulianDay() - nt1.getJulianDay());

    Date d1 = Date.ofEpochMilli(cal1.getTimeInMillis());
    Assert.assertEquals("0005-01-01", d1.toString());

    Date d2 = Date.ofEpochMilli(cal2.getTimeInMillis());
    Assert.assertEquals("2005-01-31", d2.toString());
  }
Tests util-libraries used for parquet-timestamp.
ql/src/test/org/apache/hadoop/hive/ql/io/parquet/serde/TestParquetTimestampUtils.java