本文整理了Java中org.apache.hadoop.hive.common.type.Date.setDayOfMonth()
方法的一些代码示例,展示了Date.setDayOfMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.setDayOfMonth()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.common.type.Date
类名称:Date
方法名:setDayOfMonth
暂无
代码示例来源: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
/**
* Read 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 (D+19000000).ToString -> YYYYMMDD,
* eg: Date 07 b2 01 00 -> 111111 in little endian -> 19111111 - > 1911.11.11.
* the null date will use 0 to pad.
*
* @return the date
* @throws IOException the io exception
* @throws ParseException the parse exception
*/
public Date readDate() throws IOException, ParseException {
int di = readInt();
if (di == 0) {
return null;
}
String dateString = String.valueOf(di + 19000000);
if (dateString.length() < DATE_STRING_LENGTH) {
dateString = StringUtils.leftPad(dateString, DATE_STRING_LENGTH, '0');
}
Date date = new Date();
date.setYear(Integer.parseInt(dateString.substring(0, 4)));
date.setMonth(Integer.parseInt(dateString.substring(4, 6)));
date.setDayOfMonth(Integer.parseInt(dateString.substring(6, 8)));
return date;
}
代码示例来源:origin: apache/hive
protected Date lastDay(Date d) {
date.setTimeInDays(d.toEpochDay());
date.setDayOfMonth(date.lengthOfMonth());
return date;
}
}
内容来源于网络,如有侵权,请联系作者删除!