org.apache.hadoop.hive.common.type.Date.getMonth()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.apache.hadoop.hive.common.type.Date.getMonth()方法的一些代码示例,展示了Date.getMonth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.getMonth()方法的具体详情如下:
包路径:org.apache.hadoop.hive.common.type.Date
类名称:Date
方法名:getMonth

Date.getMonth介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
 Date date = getDateValue(arguments, 0, inputTypes, converters);
 if (date == null) {
  return null;
 }
 int month = date.getMonth() - 1;
 int quarter = (month + 3) / 3;
 output.set(quarter);
 return output;
}

代码示例来源:origin: apache/hive

private Date evalDate(Date d) throws UDFArgumentException {
 date.setTimeInDays(d.toEpochDay());
 if ("MONTH".equals(fmtInput) || "MON".equals(fmtInput) || "MM".equals(fmtInput)) {
  date.setDayOfMonth(1);
  return date;
 } else if ("QUARTER".equals(fmtInput) || "Q".equals(fmtInput)) {
  int month = date.getMonth() - 1;
  int quarter = month / 3;
  int monthToSet = quarter * 3 + 1;
  date.setMonth(monthToSet);
  date.setDayOfMonth(1);
  return date;
 } else if ("YEAR".equals(fmtInput) || "YYYY".equals(fmtInput) || "YY".equals(fmtInput)) {
  date.setMonth(1);
  date.setDayOfMonth(1);
  return date;
 } else {
  return null;
 }
}

代码示例来源:origin: apache/hive

@Override
Date transform(final Date value) {
 int actualMonthValue = maskedMonthValue + 1;
 int year  = maskedYearValue  == UNMASKED_VAL ? value.getYear()  : maskedYearValue;
 int month = maskedMonthValue == UNMASKED_VAL ? value.getMonth() : actualMonthValue;
 int day   = maskedDayValue   == UNMASKED_VAL ? value.getDay()  : maskedDayValue;
 return Date.of(year, month, day);
}

代码示例来源:origin: apache/hive

/**
 * Write DATE.
 * The representation of date in Teradata binary format is:
 * The Date D is a int with 4 bytes using little endian.
 * The representation is (YYYYMMDD - 19000000).toInt -> D
 * eg. 1911.11.11 -> 19111111 -> 111111 -> 07 b2 01 00 in little endian.
 * the null date will use 0 to pad.
 *
 * @param date the date
 * @throws IOException the io exception
 */
public void writeDate(DateWritableV2 date) throws IOException {
 if (date == null) {
  EndianUtils.writeSwappedInteger(this, 0);
  return;
 }
 int toWrite = date.get().getYear() * 10000 + date.get().getMonth() * 100 + date.get().getDay() - 19000000;
 EndianUtils.writeSwappedInteger(this, toWrite);
}

代码示例来源:origin: apache/hive

result = new DateTime(d.getYear(), d.getMonth(), d.getDay(), 0, 0, DateTimeZone.UTC);
 break;
case TIMESTAMP:

代码示例来源:origin: org.apache.hive.hcatalog/hive-hcatalog-pig-adapter

result = new DateTime(d.getYear(), d.getMonth(), d.getDay(), 0, 0, DateTimeZone.UTC);
 break;
case TIMESTAMP:

相关文章