提交 63f6a13e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Inline DateTimeUtils.getYear(Calendar)

上级 9b2bbeb2
...@@ -628,20 +628,6 @@ public class DateTimeUtils { ...@@ -628,20 +628,6 @@ public class DateTimeUtils {
return ValueTimestamp.fromDateValueAndNanos(dateValue, timeNanos); return ValueTimestamp.fromDateValueAndNanos(dateValue, timeNanos);
} }
/**
* Get the year (positive or negative) from a calendar.
*
* @param calendar the calendar
* @return the year
*/
private static int getYear(Calendar calendar) {
int year = calendar.get(Calendar.YEAR);
if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
year = 1 - year;
}
return year;
}
/** /**
* Get the number of milliseconds since 1970-01-01 in the local timezone, * Get the number of milliseconds since 1970-01-01 in the local timezone,
* but without daylight saving time into account. * but without daylight saving time into account.
...@@ -1069,10 +1055,12 @@ public class DateTimeUtils { ...@@ -1069,10 +1055,12 @@ public class DateTimeUtils {
* @return the date value * @return the date value
*/ */
private static long dateValueFromCalendar(Calendar cal) { private static long dateValueFromCalendar(Calendar cal) {
int year, month, day; int year = cal.get(Calendar.YEAR);
year = getYear(cal); if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
month = cal.get(Calendar.MONTH) + 1; year = 1 - year;
day = cal.get(Calendar.DAY_OF_MONTH); }
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
return ((long) year << SHIFT_YEAR) | (month << SHIFT_MONTH) | day; return ((long) year << SHIFT_YEAR) | (month << SHIFT_MONTH) | day;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论