Java Code Examples for org.joda.time.format.DateTimeFormatter#printTo()

The following examples show how to use org.joda.time.format.DateTimeFormatter#printTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LimitChronology.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public String getMessage() {
    StringBuffer buf = new StringBuffer(85);
    buf.append("The");
    String desc = super.getMessage();
    if (desc != null) {
        buf.append(' ');
        buf.append(desc);
    }
    buf.append(" instant is ");

    DateTimeFormatter p = ISODateTimeFormat.dateTime();
    p = p.withChronology(getBase());
    if (iIsLow) {
        buf.append("below the supported minimum of ");
        p.printTo(buf, getLowerLimit().getMillis());
    } else {
        buf.append("above the supported maximum of ");
        p.printTo(buf, getUpperLimit().getMillis());
    }
    
    buf.append(" (");
    buf.append(getBase());
    buf.append(')');

    return buf.toString();
}
 
Example 2
Source File: LimitChronology.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
public String getMessage() {
    StringBuffer buf = new StringBuffer(85);
    buf.append("The");
    String desc = super.getMessage();
    if (desc != null) {
        buf.append(' ');
        buf.append(desc);
    }
    buf.append(" instant is ");

    DateTimeFormatter p = ISODateTimeFormat.dateTime();
    p = p.withChronology(getBase());
    if (iIsLow) {
        buf.append("below the supported minimum of ");
        p.printTo(buf, getLowerLimit().getMillis());
    } else {
        buf.append("above the supported maximum of ");
        p.printTo(buf, getUpperLimit().getMillis());
    }
    
    buf.append(" (");
    buf.append(getBase());
    buf.append(')');

    return buf.toString();
}
 
Example 3
Source File: TimeInterval.java    From FROST-Server with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String asISO8601() {
    DateTimeFormatter printer = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
    printer = printer.withChronology(interval.getChronology());
    StringBuilder timeString = new StringBuilder(48);
    printer.printTo(timeString, interval.getStartMillis());
    timeString.append('/');
    printer.printTo(timeString, interval.getEndMillis());
    return timeString.toString();
}
 
Example 4
Source File: AbstractInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Output a string in ISO8601 interval format.
 * <p>
 * From version 2.1, the string includes the time zone offset.
 *
 * @return re-parsable string (in the default zone)
 */
public String toString() {
    DateTimeFormatter printer = ISODateTimeFormat.dateTime();
    printer = printer.withChronology(getChronology());
    StringBuffer buf = new StringBuffer(48);
    printer.printTo(buf, getStartMillis());
    buf.append('/');
    printer.printTo(buf, getEndMillis());
    return buf.toString();
}
 
Example 5
Source File: AbstractInterval.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Output a string in ISO8601 interval format.
 * <p>
 * From version 2.1, the string includes the time zone offset.
 *
 * @return re-parsable string (in the default zone)
 */
public String toString() {
    DateTimeFormatter printer = ISODateTimeFormat.dateTime();
    printer = printer.withChronology(getChronology());
    StringBuffer buf = new StringBuffer(48);
    printer.printTo(buf, getStartMillis());
    buf.append('/');
    printer.printTo(buf, getEndMillis());
    return buf.toString();
}
 
Example 6
Source File: EPLUtilities.java    From jetstream-esper with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param key
 *          - should be a field from the incoming event. This parameter is required only because Esper calls a method
 *          taking no arguments or constant values for all arguments only once in the entire run. To make Esper call
 *          the method for every event, the argument passed in to the method must be a field in the event. Esper 3.0
 *          has a config option to turn off this behaviour completely. The only option available in Esper 2.3 is to
 *          pass an argument.
 * @return
 */
public static String getCurrentDateInISO8601Format(Object key) {

  StringBuffer buf = new StringBuffer();
  DateTimeFormatter fmt = ISODateTimeFormat.basicDateTimeNoMillis();

  fmt.printTo(buf, System.currentTimeMillis());

  return buf.toString();
}