private void displayFile(String description, File file) {
   System.out.println(
       description
           + ' '
           + DateFormatUtils.ISO_DATETIME_FORMAT.format(file.lastModified())
           + ' '
           + file.getPath().substring(getBasedir().length()));
 }
 /**
  * @param artifact
  * @return String representation of the artifact version
  */
 private String buildOptionName(ArtifactInfo artifact) {
   StringBuilder name = new StringBuilder();
   name.append(artifact.version);
   name.append(" (");
   name.append(DateFormatUtils.ISO_DATETIME_FORMAT.format(artifact.lastModified));
   name.append(")");
   return name.toString();
 }
  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);
  }
Exemple #4
0
 /**
  * Formats a timestamp in the format expected by Sentry.
  *
  * @param timestamp timestamp to format
  * @return formatted timestamp
  */
 protected String formatTimestamp(long timestamp) {
   return DateFormatUtils.formatUTC(timestamp, DateFormatUtils.ISO_DATETIME_FORMAT.getPattern());
 }