### Question:
LogicalGenerator { public long parseTimeFormat(String timestampStr) throws LogicalOperatorException { if (timestampStr == null || timestampStr.trim().equals("")) { throw new LogicalOperatorException("input timestamp cannot be empty"); } if (timestampStr.toLowerCase().equals(SQLConstant.NOW_FUNC)) { return System.currentTimeMillis(); } try { return DatetimeUtils.convertDatetimeStrToMillisecond(timestampStr, zoneId); } catch (Exception e) { throw new LogicalOperatorException(String .format("Input time format %s error. " + "Input like yyyy-MM-dd HH:mm:ss, yyyy-MM-ddTHH:mm:ss or " + "refer to user document for more info.", timestampStr)); } } LogicalGenerator(ZoneId zoneId); RootOperator getLogicalPlan(AstNode astNode); long parseTimeFormat(String timestampStr);  }### Answer:
@Test public void testParseTimeFormatNow() throws LogicalOperatorException { long now = generator.parseTimeFormat(SQLConstant.NOW_FUNC); for (int i = 0; i <= 12; i++) { ZoneOffset offset1, offset2; if (i < 10) { offset1 = ZoneOffset.of("+0" + i + ":00"); offset2 = ZoneOffset.of("-0" + i + ":00"); } else { offset1 = ZoneOffset.of("+" + i + ":00"); offset2 = ZoneOffset.of("-" + i + ":00"); } ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(now), ZoneId.of(offset1.toString())); assertEquals(now, zonedDateTime.toInstant().toEpochMilli()); zonedDateTime = ZonedDateTime .ofInstant(Instant.ofEpochMilli(now), ZoneId.of(offset2.toString())); assertEquals(now, zonedDateTime.toInstant().toEpochMilli()); } }
@Test(expected = LogicalOperatorException.class) public void testParseTimeFormatFail1() throws LogicalOperatorException { generator.parseTimeFormat(null); }
@Test(expected = LogicalOperatorException.class) public void testParseTimeFormatFail2() throws LogicalOperatorException { generator.parseTimeFormat(""); }