FormatDate extends StroomExtensionFunctionCall { long parseDate(final XPathContext context, final String value, final String pattern, final String timeZone) { final Key key = new Key(pattern, timeZone); final Function<String, Long> parser = cachedParsers.computeIfAbsent(key, k -> createParser(context, k.pattern, k.timeZone)); return parser.apply(value); } @Inject  FormatDate(final MetaHolder metaHolder);   }
@Test void testParseManualTimeZones() { long date; final FormatDate formatDate = new FormatDate(null); date = formatDate.parseDate(null, "2001/08/01", "yyyy/MM/dd", "-07:00"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-08-01T07:00:00.000Z"); date = formatDate.parseDate(null, "2001/08/01 01:00:00", "yyyy/MM/dd HH:mm:ss", "-08:00"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-08-01T09:00:00.000Z"); date = formatDate.parseDate(null, "2001/08/01 01:00:00", "yyyy/MM/dd HH:mm:ss", "+01:00"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-08-01T00:00:00.000Z"); }
@Test void testParse() { long date; final FormatDate formatDate = new FormatDate(null); date = formatDate.parseDate(null, "2001/01/01", "yyyy/MM/dd", null); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-01-01T00:00:00.000Z"); date = formatDate.parseDate(null, "2001/08/01", "yyyy/MM/dd", "GMT"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-08-01T00:00:00.000Z"); date = formatDate.parseDate(null, "2001/08/01 00:00:00.000", "yyyy/MM/dd HH:mm:ss.SSS", "GMT"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-08-01T00:00:00.000Z"); date = formatDate.parseDate(null, "2001/08/01 00:00:00", "yyyy/MM/dd HH:mm:ss", "Europe/London"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-07-31T23:00:00.000Z"); date = formatDate.parseDate(null, "2001/01/01", "yyyy/MM/dd", "GMT"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2001-01-01T00:00:00.000Z"); date = formatDate.parseDate(null, "2008/08/08:00:00:00", "yyyy/MM/dd:HH:mm:ss", "Europe/London"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2008-08-07T23:00:00.000Z"); date = formatDate.parseDate(null, "2008/08/08", "yyyy/MM/dd", "Europe/London"); assertThat(DateUtil.createNormalDateTimeString(date)).isEqualTo("2008-08-07T23:00:00.000Z"); }