diff options
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs index 16023209e..94963a19c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs @@ -520,25 +520,11 @@ namespace System.Globalization throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue); } - internal override Boolean TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result) + internal override bool TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result) { if (era == CurrentEra || era == ADEra) { - try - { - result = new DateTime(year, month, day, hour, minute, second, millisecond); - return true; - } - catch (ArgumentOutOfRangeException) - { - result = DateTime.Now; - return false; - } - catch (ArgumentException) - { - result = DateTime.Now; - return false; - } + return DateTime.TryCreate(year, month, day, hour, minute, second, millisecond, out result); } result = DateTime.MinValue; return false; |