提交 7e4e1b18 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use constant and add comments about division

上级 84801fc0
...@@ -1063,8 +1063,9 @@ public class DateTimeUtils { ...@@ -1063,8 +1063,9 @@ public class DateTimeUtils {
*/ */
public static long dateValueFromDate(long ms) { public static long dateValueFromDate(long ms) {
ms += getTimeZone().getOffset(ms); ms += getTimeZone().getOffset(ms);
long absoluteDay = ms / 86_400_000; long absoluteDay = ms / MILLIS_PER_DAY;
if (ms < 0 && (absoluteDay * 86_400_000 != ms)) { // Round toward negative infinity
if (ms < 0 && (absoluteDay * MILLIS_PER_DAY != ms)) {
absoluteDay--; absoluteDay--;
} }
return dateValueFromAbsoluteDay(absoluteDay); return dateValueFromAbsoluteDay(absoluteDay);
...@@ -1095,11 +1096,12 @@ public class DateTimeUtils { ...@@ -1095,11 +1096,12 @@ public class DateTimeUtils {
*/ */
public static long nanosFromDate(long ms) { public static long nanosFromDate(long ms) {
ms += getTimeZone().getOffset(ms); ms += getTimeZone().getOffset(ms);
long absoluteDay = ms / 86_400_000; long absoluteDay = ms / MILLIS_PER_DAY;
if (ms < 0 && (absoluteDay * 86_400_000 != ms)) { // Round toward negative infinity
if (ms < 0 && (absoluteDay * MILLIS_PER_DAY != ms)) {
absoluteDay--; absoluteDay--;
} }
return (ms - absoluteDay * 86_400_000) * 1_000_000; return (ms - absoluteDay * MILLIS_PER_DAY) * 1_000_000;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论