Example usage for org.joda.time.format DateTimeFormatterBuilder DateTimeFormatterBuilder

List of usage examples for org.joda.time.format DateTimeFormatterBuilder DateTimeFormatterBuilder

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatterBuilder DateTimeFormatterBuilder.

Prototype

public DateTimeFormatterBuilder() 

Source Link

Document

Creates a DateTimeFormatterBuilder.

Usage

From source file:com.yourmediashelf.fedora.util.DateUtility.java

License:Open Source License

/**
 * Returns an xsd:dateTime formatter with the specified millisecond precision.
 *
 * @param millisLength number of digits of millisecond precision. Currently,
 * only 0-3 are valid arguments.// w  w w .j  av  a2 s.co m
 * @return a formatter for yyyy-MM-dd'T'HH:mm:ss[.SSS]Z
 */
public static DateTimeFormatter getXSDFormatter(int millisLength) {
    String key = String.valueOf(millisLength);
    if (formatters.get(key) == null) {
        DateTimeFormatterBuilder bldr = new DateTimeFormatterBuilder().appendYear(4, 9).appendLiteral('-')
                .appendMonthOfYear(2).appendLiteral('-').appendDayOfMonth(2).appendLiteral('T')
                .appendHourOfDay(2).appendLiteral(':').appendMinuteOfHour(2).appendLiteral(':')
                .appendSecondOfMinute(2);
        if (millisLength > 0) {
            bldr = bldr.appendLiteral('.').appendFractionOfSecond(millisLength, millisLength);
        }
        bldr = bldr.appendTimeZoneOffset("Z", true, 2, 4);
        formatters.putIfAbsent(key, bldr.toFormatter());
    }
    return formatters.get(key);
}

From source file:config.TimeManipulation.java

License:Open Source License

public String getServerTime(int Offset) {
    LocalTime Time = new LocalTime();
    Time = Time.plusHours(Offset);
    DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern("HH:mm").toFormatter();
    return Time.toString(outputFormat);
}

From source file:de.codesourcery.threadwatcher.HiResInterval.java

License:Apache License

public String toUIString() {
    DateTimeFormatter DF = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral('-')
            .appendMonthOfYear(1).appendLiteral('-').appendDayOfMonth(1).appendLiteral(" ").appendHourOfDay(2)
            .appendLiteral(':').appendMinuteOfHour(2).appendLiteral(':').appendSecondOfMinute(2)
            .appendLiteral('.').appendMillisOfSecond(1).toFormatter();

    final String start = DF.print(this.start.toDateTime());
    final String end = DF.print(this.end.toDateTime());
    return start + " - " + end + " [ " + getDurationInMilliseconds() + " ms ]";
}

From source file:de.codesourcery.threadwatcher.HiResTimestamp.java

License:Apache License

public String toUIString() {
    DateTimeFormatter DF = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral('-')
            .appendMonthOfYear(1).appendLiteral('-').appendDayOfMonth(1).appendLiteral(" ").appendHourOfDay(2)
            .appendLiteral(':').appendMinuteOfHour(2).appendLiteral(':').appendSecondOfMinute(2)
            .appendLiteral('.').appendMillisOfSecond(1).toFormatter();

    return DF.print(toDateTime());
}

From source file:de.peterspan.csv2db.util.DateTimeParserHelper.java

License:Open Source License

private DateTimeParserHelper() {
    DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
            DateTimeFormat.forPattern("yyyyMMdd").getParser(),
            DateTimeFormat.forPattern("yyyy.MM.dd").getParser(),
            DateTimeFormat.forPattern("dd.MM.yyyy").getParser(),
            DateTimeFormat.forPattern("dd-MM-yyyy").getParser(),
            DateTimeFormat.forPattern("ddMMyyyy").getParser() };
    formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
}

From source file:dk.teachus.frontend.utils.Formatters.java

License:Apache License

public static DateTimeFormatter getFormatPrettyDate() {
    return new DateTimeFormatterBuilder().appendDayOfWeekShortText().appendLiteral(", ") //$NON-NLS-1$
            .appendDayOfMonth(1).appendLiteral(". ") //$NON-NLS-1$
            .appendMonthOfYearShortText().appendLiteral(' ').appendYear(4, 4).toFormatter()
            .withLocale(Session.get().getLocale());
}

From source file:dk.teachus.frontend.utils.Formatters.java

License:Apache License

public static DateTimeFormatter getFormatShortPrettyDate() {
    return new DateTimeFormatterBuilder().appendDayOfMonth(1).appendLiteral(". ") //$NON-NLS-1$
            .appendMonthOfYearShortText().appendLiteral(' ').appendYear(4, 4).toFormatter()
            .withLocale(Session.get().getLocale());
}

From source file:dk.teachus.frontend.utils.Formatters.java

License:Apache License

public static DateTimeFormatter getFormatWeekDay() {
    return new DateTimeFormatterBuilder().appendDayOfWeekText().toFormatter()
            .withLocale(Session.get().getLocale());
}

From source file:dk.teachus.frontend.utils.Formatters.java

License:Apache License

public static DateTimeFormatter getFormatWeekDayShort() {
    return new DateTimeFormatterBuilder().appendDayOfWeekShortText().toFormatter()
            .withLocale(Session.get().getLocale());
}

From source file:dk.teachus.frontend.utils.Formatters.java

License:Apache License

public static DateTimeFormatter getFormatMonthYear() {
    return new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral('-').appendMonthOfYear(2).toFormatter()
            .withLocale(Session.get().getLocale());
}