This commit is contained in:
Looly
2022-08-30 23:32:15 +08:00
parent 4e8060e441
commit fe6c48f08d
3 changed files with 15 additions and 15 deletions

View File

@@ -114,7 +114,9 @@ public class TemporalAccessorUtil extends TemporalUtil{
/**
* {@link TemporalAccessor}转换为 时间戳从1970-01-01T00:00:00Z开始的毫秒数<br>
* 如果为{@link Month},调用{@link Month#getValue()}
* 如果为{@link Month},调用{@link Month#getValue()}<br>
* 如果为{@link DayOfWeek},调用{@link DayOfWeek#getValue()}<br>
* 如果为{@link Era},调用{@link Era#getValue()}
*
* @param temporalAccessor Date对象
* @return {@link Instant}对象
@@ -123,6 +125,10 @@ public class TemporalAccessorUtil extends TemporalUtil{
public static long toEpochMilli(final TemporalAccessor temporalAccessor) {
if(temporalAccessor instanceof Month){
return ((Month) temporalAccessor).getValue();
} else if(temporalAccessor instanceof DayOfWeek){
return ((DayOfWeek) temporalAccessor).getValue();
} else if(temporalAccessor instanceof Era){
return ((Era) temporalAccessor).getValue();
}
return toInstant(temporalAccessor).toEpochMilli();
}