本文整理了Java中org.apache.hadoop.hive.ql.io.parquet.timestamp.NanoTime.getTimeOfDayNanos()
方法的一些代码示例,展示了NanoTime.getTimeOfDayNanos()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NanoTime.getTimeOfDayNanos()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.io.parquet.timestamp.NanoTime
类名称:NanoTime
方法名:getTimeOfDayNanos
暂无
代码示例来源:origin: apache/drill
public static Timestamp getTimestamp(NanoTime nt, boolean skipConversion) {
int julianDay = nt.getJulianDay();
long nanosOfDay = nt.getTimeOfDayNanos();
代码示例来源:origin: apache/hive
public static Timestamp getTimestamp(NanoTime nt, boolean skipConversion) {
int julianDay = nt.getJulianDay();
long nanosOfDay = nt.getTimeOfDayNanos();
代码示例来源:origin: apache/hive
public void testTimezone() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1968);
cal.set(Calendar.MONTH, Calendar.MAY);
cal.set(Calendar.DAY_OF_MONTH, 23);
cal.set(Calendar.HOUR_OF_DAY, 17);
cal.set(Calendar.MINUTE, 1);
cal.set(Calendar.SECOND, 1);
cal.setTimeZone(TimeZone.getTimeZone("US/Pacific"));
Timestamp ts = Timestamp.ofEpochMilli(cal.getTimeInMillis(), 1);
/**
* 17:00 PDT = 00:00 GMT (daylight-savings)
* (0*60*60 + 1*60 + 1)*10e9 + 1 = 61000000001, or
*
* 17:00 PST = 01:00 GMT (if not daylight savings)
* (1*60*60 + 1*60 + 1)*10e9 + 1 = 3661000000001
*/
NanoTime nt = NanoTimeUtils.getNanoTime(ts, false);
long timeOfDayNanos = nt.getTimeOfDayNanos();
Assert.assertTrue(timeOfDayNanos == 61000000001L || timeOfDayNanos == 3661000000001L);
//in both cases, this will be the next day in GMT
Assert.assertEquals(nt.getJulianDay(), 2440001);
}
代码示例来源:origin: apache/hive
Assert.assertEquals(nt.getTimeOfDayNanos(), 3661000000001L);
Assert.assertEquals(nt.getTimeOfDayNanos(), 86399999999999L);
NanoTime n1 = NanoTimeUtils.getNanoTime(ts1, false);
Assert.assertEquals(n2.getTimeOfDayNanos() - n1.getTimeOfDayNanos(), 600000000009L);
NanoTime n3 = new NanoTime(n1.getJulianDay() - 1, n1.getTimeOfDayNanos() + TimeUnit.DAYS.toNanos(1));
Assert.assertEquals(ts1, NanoTimeUtils.getTimestamp(n3, false));
n3 = new NanoTime(n1.getJulianDay() + 3, n1.getTimeOfDayNanos() - TimeUnit.DAYS.toNanos(3));
Assert.assertEquals(ts1, NanoTimeUtils.getTimestamp(n3, false));
代码示例来源:origin: apache/hive
public void testTimezoneless() {
Timestamp ts1 = Timestamp.valueOf("2011-01-01 00:30:30.111111111");
NanoTime nt1 = NanoTimeUtils.getNanoTime(ts1, true);
Assert.assertEquals(nt1.getJulianDay(), 2455562);
Assert.assertEquals(nt1.getTimeOfDayNanos(), 59430111111111L);
Timestamp ts1Fetched = NanoTimeUtils.getTimestamp(nt1, true);
Assert.assertEquals(ts1Fetched.toString(), ts1.toString());
Timestamp ts2 = Timestamp.valueOf("2011-02-02 08:30:30.222222222");
NanoTime nt2 = NanoTimeUtils.getNanoTime(ts2, true);
Assert.assertEquals(nt2.getJulianDay(), 2455595);
Assert.assertEquals(nt2.getTimeOfDayNanos(), 1830222222222L);
Timestamp ts2Fetched = NanoTimeUtils.getTimestamp(nt2, true);
Assert.assertEquals(ts2Fetched.toString(), ts2.toString());
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
public static Timestamp getTimestamp(NanoTime nt, boolean skipConversion) {
int julianDay = nt.getJulianDay();
long nanosOfDay = nt.getTimeOfDayNanos();
JDateTime jDateTime = new JDateTime((double) julianDay);
Calendar calendar = getCalendar(skipConversion);
calendar.set(Calendar.YEAR, jDateTime.getYear());
calendar.set(Calendar.MONTH, jDateTime.getMonth() - 1); //java calender index starting at 1.
calendar.set(Calendar.DAY_OF_MONTH, jDateTime.getDay());
long remainder = nanosOfDay;
int hour = (int) (remainder / (NANOS_PER_HOUR));
remainder = remainder % (NANOS_PER_HOUR);
int minutes = (int) (remainder / (NANOS_PER_MINUTE));
remainder = remainder % (NANOS_PER_MINUTE);
int seconds = (int) (remainder / (NANOS_PER_SECOND));
long nanos = remainder % NANOS_PER_SECOND;
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minutes);
calendar.set(Calendar.SECOND, seconds);
Timestamp ts = new Timestamp(calendar.getTimeInMillis());
ts.setNanos((int) nanos);
return ts;
}
}
内容来源于网络,如有侵权,请联系作者删除!