public void GetJavaDate_ValidValue() { double dateValue = 0; TimeZoneInfo tz = LocaleUtil.GetUserTimeZoneInfo(); bool use1904windowing = false; bool roundSeconds = false; DateTime calendar = LocaleUtil.GetLocaleCalendar(1900, 1, 0); //Date date = calendar.GetTime(); DateTime date = calendar; Assert.AreEqual(date, DateUtil.GetJavaDate(dateValue)); Assert.AreEqual(date, DateUtil.GetJavaDate(dateValue, tz)); Assert.AreEqual(date, DateUtil.GetJavaDate(dateValue, use1904windowing)); Assert.AreEqual(date, DateUtil.GetJavaDate(dateValue, use1904windowing, tz)); Assert.AreEqual(date, DateUtil.GetJavaDate(dateValue, use1904windowing, tz, roundSeconds)); }
public void GetJavaDate_InvalidValue() { double dateValue = -1; TimeZoneInfo tz = LocaleUtil.GetUserTimeZoneInfo(); bool use1904windowing = false; bool roundSeconds = false; try { DateUtil.GetJavaDate(dateValue); Assert.Fail("invalid datetime double value -1"); } catch (ArgumentException) { } try { DateUtil.GetJavaDate(dateValue, tz); Assert.Fail("invalid datetime double value -1"); } catch (ArgumentException) { } try { DateUtil.GetJavaDate(dateValue, use1904windowing); Assert.Fail("invalid datetime double value -1"); } catch (ArgumentException) { } try { DateUtil.GetJavaDate(dateValue, use1904windowing, tz); Assert.Fail("invalid datetime double value -1"); } catch (ArgumentException) { } try { DateUtil.GetJavaDate(dateValue, use1904windowing, tz, roundSeconds); Assert.Fail("invalid datetime double value -1"); } catch (ArgumentException) { } //Assert.AreEqual(null, DateUtil.GetJavaDate(dateValue)); //Assert.AreEqual(null, DateUtil.GetJavaDate(dateValue, tz)); //Assert.AreEqual(null, DateUtil.GetJavaDate(dateValue, use1904windowing)); //Assert.AreEqual(null, DateUtil.GetJavaDate(dateValue, use1904windowing, tz)); //Assert.AreEqual(null, DateUtil.GetJavaDate(dateValue, use1904windowing, tz, roundSeconds)); }
public void GetJavaCalendar_ValidValue() { double dateValue = 0; TimeZoneInfo tz = LocaleUtil.GetUserTimeZoneInfo(); bool use1904windowing = false; bool roundSeconds = false; DateTime expCal = LocaleUtil.GetLocaleCalendar(1900, 1, 0); DateTime[] actCal = { DateUtil.GetJavaCalendar(dateValue), DateUtil.GetJavaCalendar(dateValue, use1904windowing), DateUtil.GetJavaCalendar(dateValue, use1904windowing, tz), DateUtil.GetJavaCalendar(dateValue, use1904windowing, tz, roundSeconds) }; Assert.AreEqual(expCal, actCal[0]); Assert.AreEqual(expCal, actCal[1]); Assert.AreEqual(expCal, actCal[2]); Assert.AreEqual(expCal, actCal[3]); }