Example usage for org.apache.commons.lang3.time DateFormatUtils ISO_DATETIME_FORMAT

List of usage examples for org.apache.commons.lang3.time DateFormatUtils ISO_DATETIME_FORMAT

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time DateFormatUtils ISO_DATETIME_FORMAT.

Prototype

FastDateFormat ISO_DATETIME_FORMAT

To view the source code for org.apache.commons.lang3.time DateFormatUtils ISO_DATETIME_FORMAT.

Click Source Link

Document

ISO 8601 formatter for date-time without time zone.

Usage

From source file:com.trenako.web.infrastructure.RangeRequestQueryParamsBuilder.java

/**
 * Builds the query parameters for the provided parameters {@code Map}.
 *
 * @param params the parameters//from w w w .j a va2 s  . c  o m
 * @param range  range id
 * @return the query parameters
 * @throws UnsupportedEncodingException
 */
static String buildQueryParams(Map<String, Object> params, String range) throws UnsupportedEncodingException {
    StringBuilder sb = new StringBuilder();

    boolean first = true;
    for (Map.Entry<String, Object> entry : params.entrySet()) {

        if (RANGE_NAMES.contains(entry.getKey()) && !entry.getKey().equals(range)) {
            continue;
        }

        if (first) {
            sb.append("?");
            first = false;
        } else {
            sb.append("&");
        }

        String val;
        if (entry.getValue() instanceof Date) {
            val = DateFormatUtils.format((Date) entry.getValue(),
                    DateFormatUtils.ISO_DATETIME_FORMAT.getPattern());
        } else {
            val = entry.getValue().toString();
        }
        sb.append(entry.getKey()).append("=").append(URLEncoder.encode(val, "UTF-8"));
    }

    return sb.toString();
}

From source file:com.trenako.web.infrastructure.RangeRequestArgumentResolver.java

private Date parseDate(Object since) {
    if (since == null)
        return null;

    try {/*www. ja  v  a  2 s . c om*/
        return DateUtils.parseDate(since.toString(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern());
    } catch (Exception e) {
        return null;
    }
}

From source file:eu.chocolatejar.eclipse.plugin.cleaner.Main.java

/**
 * The default destination is based on the <source
 * folder>/duplicates_<timestamp>
 * /*  w w  w  .j  av a  2s.  c o m*/
 * @param sourceFolder
 *            cannot be <code>null</code>
 * @return absolute path
 */
String getDefaultDestinationFolder(File sourceFolder) {
    assert sourceFolder != null;
    File file = FileUtils.getFile(sourceFolder,
            "duplicates_" + DateFormatUtils.ISO_DATETIME_FORMAT.format(new Date()));
    return file.getAbsolutePath();

}

From source file:net.larry1123.elec.util.logger.LoggerDirectoryHandler.java

/**
 * Makes a formatted String/*from  w ww  . j  a  va2 s  . c om*/
 *
 * @param milli What milli time to use
 *
 * @return The formatted String
 */
public String getDateFormatFromMilli(long milli) {
    return DateFormatUtils.ISO_DATETIME_FORMAT.format(milli).replace(":", File.pathSeparator);
}

From source file:gov.nih.nci.firebird.web.action.sponsor.annual.registration.BrowseRegistrationsActionTest.java

private void verifyRegistrationInJson(String json, AnnualRegistration registration) {
    assertTrue(json.contains(registration.getId().toString()));
    assertTrue(json.contains(registration.getProfile().getPerson().getDisplayNameForList()));
    assertTrue(json.contains(trimToEmpty(registration.getProfile().getPerson().getCtepId())));
    assertTrue(json.contains(registration.getProfile().getPerson().getEmail()));
    assertTrue(json.contains(registration.getAnnualRegistrationType().getDisplay()));
    assertTrue(json.contains(registration.getStatus().getDisplay()));
    if (registration.getLastSubmissionDate() != null) {
        String lastSubmissionDate = DateFormatUtils.ISO_DATETIME_FORMAT
                .format(registration.getLastSubmissionDate());
        assertTrue(json.contains(lastSubmissionDate));
        String renewalDate = DateFormatUtils.ISO_DATETIME_FORMAT
                .format(DateUtils.addYears(registration.getLastSubmissionDate(), 1));
        assertTrue(json.contains(renewalDate));
    }//w w w . j ava 2  s.  c om
}

From source file:eu.trentorise.opendata.commons.TodUtils.java

/**
 * @deprecated experimental, try to avoid using it for now
 * @since 1.1//www  .  j  ava2  s .co  m
 * @throws TodParseException
 */
// todo this parser is horrible
public static Date parseIso8061(String s) {

    try {
        return DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    try {
        return DateFormatUtils.ISO_DATETIME_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    try {
        return DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    try {
        return DateFormatUtils.ISO_DATE_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    try {
        return ISO_YEAR_MONTH_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    try {
        return ISO_YEAR_FORMAT.parse(s);
    } catch (ParseException ex) {
    }

    // todo week dates, ordinal dates

    throw new TodParseException("Couldn't parse date as ISO8061. Unparseable date was:" + s);
}

From source file:org.amanzi.awe.statistics.dto.impl.StatisticsRow.java

@Override
public String toString() {
    String startDateString = DateFormatUtils.ISO_DATETIME_FORMAT.format(startDate);
    String endDateString = DateFormatUtils.ISO_DATETIME_FORMAT.format(endDate);

    StringBuilder builder = new StringBuilder("StatisticsRow from <").append(startDateString).append("> to <")
            .append(endDateString).append(">.");

    return builder.toString();
}

From source file:org.apache.maven.plugins.site.descriptor.EffectiveSiteMojo.java

/**
 * Write comments in the Effective POM/settings header.
 *
 * @param writer not null// w  ww.ja  v a 2  s  . co m
 */
protected static void writeHeader(XMLWriter writer) {
    XmlWriterUtil.writeCommentLineBreak(writer);
    XmlWriterUtil.writeComment(writer, " ");
    // Use ISO 8601 format for date and time
    String formattedDateTime = DateFormatUtils.ISO_DATETIME_FORMAT.format(System.currentTimeMillis());
    XmlWriterUtil.writeComment(writer, "Generated by Maven Site Plugin on " + formattedDateTime);
    XmlWriterUtil.writeComment(writer, "See: http://maven.apache.org/plugins/maven-site-plugin/");
    XmlWriterUtil.writeComment(writer, " ");
    XmlWriterUtil.writeCommentLineBreak(writer);

    XmlWriterUtil.writeLineBreak(writer);
}

From source file:org.jrb.lots.domain.Tag.java

@Override
public String toString() {
    return getClass().getSimpleName() + " [" + (id != null ? "id=" + id + ", " : "")
            + (name != null ? "name=" + name + ", " : "") + (version != null ? "version=" + version + ", " : "")
            + (description != null ? "description=" + description + ", " : "")
            + (createdOn != null ? "createdOn=" + DateFormatUtils.ISO_DATETIME_FORMAT.format(createdOn) + ", "
                    : "")
            + (updatedOn != null ? "updatedOn=" + DateFormatUtils.ISO_DATETIME_FORMAT.format(updatedOn) : "")
            + "]";
}

From source file:org.jrb.lots.domain.Thing.java

@Override
public String toString() {
    return getClass().getSimpleName() + " [" + (id != null ? "id=" + id + ", " : "")
            + (name != null ? "name=" + name + ", " : "") + (version != null ? "version=" + version + ", " : "")
            + (description != null ? "description=" + description + ", " : "")
            + (createdOn != null ? "createdOn=" + DateFormatUtils.ISO_DATETIME_FORMAT.format(createdOn) + ", "
                    : "")
            + (updatedOn != null ? "updatedOn=" + DateFormatUtils.ISO_DATETIME_FORMAT.format(updatedOn) + ", "
                    : "")
            + (tagnames != null ? "tagnames=" + tagnames : "") + "]";
}