public String toRegexForFixedDate(Date date) {
    StringBuilder buf = new StringBuilder();
    Converter<Object> p = headTokenConverter;
    while (p != null) {
      if (p instanceof LiteralConverter) {
        buf.append(p.convert(null));
      } else if (p instanceof IntegerTokenConverter) {
        buf.append(FileFinder.regexEscapePath("(\\d+)"));
      } else if (p instanceof DateTokenConverter) {
        DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p;
        if (dtc.isPrimary()) {
          buf.append(p.convert(date));
        } else {
          buf.append(FileFinder.regexEscapePath(dtc.toRegex()));
        }
      }
      p = p.getNext();
    }
    return buf.toString();
  }
@Test
  public void asRegexByDate() {

    Calendar cal = Calendar.getInstance();
    cal.set(2003, 4, 20, 17, 55);

    {
      FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd}-%i.txt",
          context);
      String regex = fnp.toRegexForFixedDate(cal.getTime());
      assertEquals("foo-2003.05.20-" + FileFinder.regexEscapePath("(\\d+)") + ".txt", regex);
    }
    {
      FileNamePattern fnp = new FileNamePattern("\\toto\\foo-%d{yyyy\\MM\\dd}-%i.txt",
          context);
      String regex = fnp.toRegexForFixedDate(cal.getTime());
      assertEquals("/toto/foo-2003/05/20-" + FileFinder.regexEscapePath("(\\d+)") + ".txt", regex);
    }
  }