public static boolean isPeriodValid(String timeStr) {
    try {
      PERIOD_FORMATTER.parsePeriod(timeStr);
      return true;
    } catch (Exception e) {
      return false;
    }
  }
@Test
  public void testIsPeriodValid() {
    Assert.assertTrue(TimeUtils.isPeriodValid("2d"));
    Assert.assertTrue(TimeUtils.isPeriodValid(""));
    Assert.assertTrue(TimeUtils.isPeriodValid("1m"));
    Assert.assertTrue(TimeUtils.isPeriodValid("2h"));
    Assert.assertTrue(TimeUtils.isPeriodValid("-2h"));
    Assert.assertTrue(TimeUtils.isPeriodValid("-2m"));
    Assert.assertTrue(TimeUtils.isPeriodValid("-4d"));
    Assert.assertFalse(TimeUtils.isPeriodValid(null));
  }