提交 9cb6e331 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Rename methods

上级 20103f32
......@@ -570,8 +570,8 @@ public class DateTimeUtils {
} else {
long millis = convertDateTimeValueToMillis(tz, dateValue, nanos / 1_000_000);
millis += getTimeZoneOffset(millis);
dateValue = dateValueFromDate(millis);
nanos = nanos % 1_000_000 + nanosFromDate(millis);
dateValue = dateValueFromLocalMillis(millis);
nanos = nanos % 1_000_000 + nanosFromLocalMillis(millis);
}
}
}
......@@ -1126,7 +1126,7 @@ public class DateTimeUtils {
* @param ms the milliseconds
* @return the date value
*/
public static long dateValueFromDate(long ms) {
public static long dateValueFromLocalMillis(long ms) {
long absoluteDay = ms / MILLIS_PER_DAY;
// Round toward negative infinity
if (ms < 0 && (absoluteDay * MILLIS_PER_DAY != ms)) {
......@@ -1157,7 +1157,7 @@ public class DateTimeUtils {
* @param ms the milliseconds
* @return the nanoseconds
*/
public static long nanosFromDate(long ms) {
public static long nanosFromLocalMillis(long ms) {
long absoluteDay = ms / MILLIS_PER_DAY;
// Round toward negative infinity
if (ms < 0 && (absoluteDay * MILLIS_PER_DAY != ms)) {
......
......@@ -1043,8 +1043,9 @@ public abstract class Value {
ValueTimestampTimeZone ts = (ValueTimestampTimeZone) this;
long dateValue = ts.getDateValue(), timeNanos = ts.getTimeNanos();
long millis = DateTimeUtils.getMillis(dateValue, timeNanos, ts.getTimeZoneOffsetMins());
return ValueTime.fromNanos(DateTimeUtils.nanosFromDate(millis + DateTimeUtils.getTimeZoneOffset(millis))
+ timeNanos % 1_000_000);
return ValueTime.fromNanos(
DateTimeUtils.nanosFromLocalMillis(millis + DateTimeUtils.getTimeZoneOffset(millis))
+ timeNanos % 1_000_000);
}
case ENUM:
throw getDataConversionError(TIME);
......
......@@ -48,7 +48,7 @@ public class ValueDate extends Value {
*/
public static ValueDate get(Date date) {
long ms = date.getTime();
return fromDateValue(DateTimeUtils.dateValueFromDate(ms + DateTimeUtils.getTimeZoneOffset(ms)));
return fromDateValue(DateTimeUtils.dateValueFromLocalMillis(ms + DateTimeUtils.getTimeZoneOffset(ms)));
}
/**
......@@ -59,7 +59,7 @@ public class ValueDate extends Value {
* @return the value
*/
public static ValueDate fromMillis(long ms) {
return fromDateValue(DateTimeUtils.dateValueFromDate(ms + DateTimeUtils.getTimeZoneOffset(ms)));
return fromDateValue(DateTimeUtils.dateValueFromLocalMillis(ms + DateTimeUtils.getTimeZoneOffset(ms)));
}
/**
......
......@@ -85,7 +85,7 @@ public class ValueTime extends Value {
*/
public static ValueTime get(Time time) {
long ms = time.getTime();
return fromNanos(DateTimeUtils.nanosFromDate(ms + DateTimeUtils.getTimeZoneOffset(ms)));
return fromNanos(DateTimeUtils.nanosFromLocalMillis(ms + DateTimeUtils.getTimeZoneOffset(ms)));
}
/**
......@@ -96,7 +96,7 @@ public class ValueTime extends Value {
* @return the value
*/
public static ValueTime fromMillis(long ms) {
return fromNanos(DateTimeUtils.nanosFromDate(ms + DateTimeUtils.getTimeZoneOffset(ms)));
return fromNanos(DateTimeUtils.nanosFromLocalMillis(ms + DateTimeUtils.getTimeZoneOffset(ms)));
}
/**
......
......@@ -90,8 +90,8 @@ public class ValueTimestamp extends Value {
long ms = timestamp.getTime();
long nanos = timestamp.getNanos() % 1_000_000;
ms += DateTimeUtils.getTimeZoneOffset(ms);
long dateValue = DateTimeUtils.dateValueFromDate(ms);
nanos += DateTimeUtils.nanosFromDate(ms);
long dateValue = DateTimeUtils.dateValueFromLocalMillis(ms);
nanos += DateTimeUtils.nanosFromLocalMillis(ms);
return fromDateValueAndNanos(dateValue, nanos);
}
......@@ -104,8 +104,8 @@ public class ValueTimestamp extends Value {
*/
public static ValueTimestamp fromMillisNanos(long ms, int nanos) {
ms += DateTimeUtils.getTimeZoneOffset(ms);
long dateValue = DateTimeUtils.dateValueFromDate(ms);
long timeNanos = nanos + DateTimeUtils.nanosFromDate(ms);
long dateValue = DateTimeUtils.dateValueFromLocalMillis(ms);
long timeNanos = nanos + DateTimeUtils.nanosFromLocalMillis(ms);
return fromDateValueAndNanos(dateValue, timeNanos);
}
......@@ -117,8 +117,8 @@ public class ValueTimestamp extends Value {
*/
public static ValueTimestamp fromMillis(long ms) {
ms += DateTimeUtils.getTimeZoneOffset(ms);
long dateValue = DateTimeUtils.dateValueFromDate(ms);
long nanos = DateTimeUtils.nanosFromDate(ms);
long dateValue = DateTimeUtils.dateValueFromLocalMillis(ms);
long nanos = DateTimeUtils.nanosFromLocalMillis(ms);
return fromDateValueAndNanos(dateValue, nanos);
}
......
......@@ -464,8 +464,8 @@ public class TestDate extends TestBase {
long millis = 1407437460000L;
long ms = DateTimeUtils.getTimeUTCWithoutDst(millis);
ms += DateTimeUtils.getTimeZoneOffset(ms);
long result1 = DateTimeUtils.nanosFromDate(ms);
long result2 = DateTimeUtils.nanosFromDate(ms);
long result1 = DateTimeUtils.nanosFromLocalMillis(ms);
long result2 = DateTimeUtils.nanosFromLocalMillis(ms);
assertEquals(result1, result2);
}
......
......@@ -160,8 +160,8 @@ public class TestDateTimeUtils extends TestBase {
long timeMillis = gc.getTimeInMillis();
ValueTimestamp ts = DateTimeUtils.convertTimestamp(new Timestamp(timeMillis), gc);
timeMillis += DateTimeUtils.getTimeZoneOffset(timeMillis);
assertEquals(ts.getDateValue(), DateTimeUtils.dateValueFromDate(timeMillis));
assertEquals(ts.getTimeNanos(), DateTimeUtils.nanosFromDate(timeMillis));
assertEquals(ts.getDateValue(), DateTimeUtils.dateValueFromLocalMillis(timeMillis));
assertEquals(ts.getTimeNanos(), DateTimeUtils.nanosFromLocalMillis(timeMillis));
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论