@Override
 public String getEntityTagValueForContentType(ContentType contentType) {
   return DigestUtils.md5Hex(
       new StringBuilder(
               DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(
                   contentType.getLastModifiedDate()))
           .append('~')
           .append(contentType.getRepresentations().get(MediaType.APPLICATION_XML))
           .toString());
 }
示例#2
0
  public static void main(String[] args) {
    Date today = new Date();

    /*
     * ISO8601 formatter for date-time without time zone.
     * The format used is yyyy-MM-dd'T'HH:mm:ss.
     */
    String timestamp = DateFormatUtils.ISO_DATETIME_FORMAT.format(today);
    System.out.println("timestamp = " + timestamp);

    /*
     * ISO8601 formatter for date-time with time zone.
     * The format used is yyyy-MM-dd'T'HH:mm:ssZZ.
     */
    timestamp = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(today);
    System.out.println("timestamp = " + timestamp);

    /*
     * The format used is <tt>EEE, dd MMM yyyy HH:mm:ss Z</tt> in US locale.
     */
    timestamp = DateFormatUtils.SMTP_DATETIME_FORMAT.format(today);
    System.out.println("timestamp = " + timestamp);
  }