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

Merge getTimeTry() into getMillis()

上级 6a57c517
...@@ -519,9 +519,15 @@ public class DateTimeUtils { ...@@ -519,9 +519,15 @@ public class DateTimeUtils {
*/ */
public static long getMillis(TimeZone tz, int year, int month, int day, public static long getMillis(TimeZone tz, int year, int month, int day,
int hour, int minute, int second, int millis) { int hour, int minute, int second, int millis) {
Calendar c;
if (tz == null) {
c = getCalendar();
} else {
c = getCalendar(tz);
}
c.setLenient(false);
try { try {
return getTimeTry(false, tz, year, month, day, hour, minute, second, return convertToMillis(c, year, month, day, hour, minute, second, millis);
millis);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// special case: if the time simply doesn't exist because of // special case: if the time simply doesn't exist because of
// daylight saving time changes, use the lenient version // daylight saving time changes, use the lenient version
...@@ -545,21 +551,9 @@ public class DateTimeUtils { ...@@ -545,21 +551,9 @@ public class DateTimeUtils {
// for example for 2042-10-12 00:00:00. // for example for 2042-10-12 00:00:00.
hour += 6; hour += 6;
} }
return getTimeTry(true, tz, year, month, day, hour, minute, c.setLenient(true);
second, millis); return convertToMillis(c, year, month, day, hour, minute, second, millis);
}
}
private static long getTimeTry(boolean lenient, TimeZone tz, int year,
int month, int day, int hour, int minute, int second, int millis) {
Calendar c;
if (tz == null) {
c = getCalendar();
} else {
c = getCalendar(tz);
} }
c.setLenient(lenient);
return convertToMillis(c, year, month, day, hour, minute, second, millis);
} }
private static long convertToMillis(Calendar cal, int year, int month, int day, private static long convertToMillis(Calendar cal, int year, int month, int day,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论