/** * Converts an integer to a string, and appends it to the given buffer. * * <p>This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(StringBuffer buf, long value) { try { appendUnpaddedInteger((Appendable) buf, value); } catch (IOException e) { // StringBuffer do not throw IOException } }
/** * Converts an integer to a string, and appends it to the given buffer. * * <p>This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(StringBuffer buf, int value) { try { appendUnpaddedInteger((Appendable) buf, value); } catch (IOException e) { // StringBuffer do not throw IOException } }
/** * Converts an integer to a string, and appends it to the given buffer. * * <p>This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(StringBuffer buf, int value) { try { appendUnpaddedInteger((Appendable) buf, value); } catch (IOException e) { // StringBuffer do not throw IOException } }
/** * Converts an integer to a string, and appends it to the given buffer. * * <p>This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(StringBuffer buf, long value) { try { appendUnpaddedInteger((Appendable) buf, value); } catch (IOException e) { // StringBuffer do not throw IOException } }
/** * Converts an integer to a string, and appends it to the given appendable. * * <p>This method is optimized for converting small values to strings. * * @param appendable receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(Appendable appendable, long value) throws IOException { int intValue = (int)value; if (intValue == value) { appendUnpaddedInteger(appendable, intValue); } else { appendable.append(Long.toString(value)); } }
/** * Converts an integer to a string, and appends it to the given appendable. * * <p>This method is optimized for converting small values to strings. * * @param appendable receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(Appendable appendable, long value) throws IOException { int intValue = (int)value; if (intValue == value) { appendUnpaddedInteger(appendable, intValue); } else { appendable.append(Long.toString(value)); } }
public void printTo(Appendable appendable, ReadablePartial partial, Locale locale) throws IOException { if (partial.isSupported(iFieldType)) { try { FormatUtils.appendUnpaddedInteger(appendable, partial.get(iFieldType)); } catch (RuntimeException e) { appendable.append('\ufffd'); } } else { appendable.append('\ufffd'); } } }
public void printTo(Appendable appendable, ReadablePartial partial, Locale locale) throws IOException { if (partial.isSupported(iFieldType)) { try { FormatUtils.appendUnpaddedInteger(appendable, partial.get(iFieldType)); } catch (RuntimeException e) { appendable.append('\ufffd'); } } else { appendable.append('\ufffd'); } } }
public void printTo( Appendable appendable, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException { try { DateTimeField field = iFieldType.getField(chrono); FormatUtils.appendUnpaddedInteger(appendable, field.get(instant)); } catch (RuntimeException e) { appendable.append('\ufffd'); } }
public void printTo( Appendable appendable, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException { try { DateTimeField field = iFieldType.getField(chrono); FormatUtils.appendUnpaddedInteger(appendable, field.get(instant)); } catch (RuntimeException e) { appendable.append('\ufffd'); } }
/** * Gets the value as a String in the ISO8601 duration format including * only seconds and milliseconds. * <p> * For example, "PT72.345S" represents 1 minute, 12 seconds and 345 milliseconds. * <p> * For more control over the output, see * {@link org.joda.time.format.PeriodFormatterBuilder PeriodFormatterBuilder}. * * @return the value as an ISO8601 string */ @ToString public String toString() { long millis = getMillis(); StringBuffer buf = new StringBuffer(); buf.append("PT"); boolean negative = (millis < 0); FormatUtils.appendUnpaddedInteger(buf, millis); while (buf.length() < (negative ? 7 : 6)) { buf.insert(negative ? 3 : 2, "0"); } if ((millis / 1000) * 1000 == millis) { buf.setLength(buf.length() - 3); } else { buf.insert(buf.length() - 3, "."); } buf.append('S'); return buf.toString(); }
/** * Gets the value as a String in the ISO8601 duration format including * only seconds and milliseconds. * <p> * For example, "PT72.345S" represents 1 minute, 12 seconds and 345 milliseconds. * <p> * For more control over the output, see * {@link org.joda.time.format.PeriodFormatterBuilder PeriodFormatterBuilder}. * * @return the value as an ISO8601 string */ @ToString public String toString() { long millis = getMillis(); StringBuffer buf = new StringBuffer(); buf.append("PT"); boolean negative = (millis < 0); FormatUtils.appendUnpaddedInteger(buf, millis); while (buf.length() < (negative ? 7 : 6)) { buf.insert(negative ? 3 : 2, "0"); } if ((millis / 1000) * 1000 == millis) { buf.setLength(buf.length() - 3); } else { buf.insert(buf.length() - 3, "."); } buf.append('S'); return buf.toString(); }
int minDigits = iMinPrintedDigits; if (minDigits <= 1) { FormatUtils.appendUnpaddedInteger(buf, value); } else { FormatUtils.appendPaddedInteger(buf, value, minDigits);
int minDigits = iMinPrintedDigits; if (minDigits <= 1) { FormatUtils.appendUnpaddedInteger(buf, value); } else { FormatUtils.appendPaddedInteger(buf, value, minDigits);
/** * Converts an integer to a string, and appends it to the given buffer. * * <p>This method is optimized for converting small values to strings. * * @param buf receives integer converted to a string * @param value value to convert to a string */ public static void appendUnpaddedInteger(StringBuffer buf, long value) { int intValue = (int)value; if (intValue == value) { appendUnpaddedInteger(buf, intValue); } else { buf.append(Long.toString(value)); } }
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) { if (partial.isSupported(iFieldType)) { try { FormatUtils.appendUnpaddedInteger(buf, partial.get(iFieldType)); } catch (RuntimeException e) { buf.append('\ufffd'); } } else { buf.append('\ufffd'); } }
public void printTo( StringBuffer buf, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) { try { DateTimeField field = iFieldType.getField(chrono); FormatUtils.appendUnpaddedInteger(buf, field.get(instant)); } catch (RuntimeException e) { buf.append('\ufffd'); } }
/** * Gets the value as a String in the ISO8601 duration format including * only seconds and milliseconds. * <p> * For example, "PT72.345S" represents 1 minute, 12 seconds and 345 milliseconds. * <p> * For more control over the output, see * {@link org.joda.time.format.PeriodFormatterBuilder PeriodFormatterBuilder}. * * @return the value as an ISO8601 string */ @ToString public String toString() { long millis = getMillis(); StringBuffer buf = new StringBuffer(); buf.append("PT"); boolean negative = (millis < 0); FormatUtils.appendUnpaddedInteger(buf, millis); while (buf.length() < (negative ? 7 : 6)) { buf.insert(negative ? 3 : 2, "0"); } if ((millis / 1000) * 1000 == millis) { buf.setLength(buf.length() - 3); } else { buf.insert(buf.length() - 3, "."); } buf.append('S'); return buf.toString(); }
public void printTo(StringBuffer buf, ReadablePeriod period, Locale locale) { long valueLong = getFieldValue(period); if (valueLong == Long.MAX_VALUE) { return; } int value = (int) valueLong; if (iFieldType >= SECONDS_MILLIS) { value = (int) (valueLong / DateTimeConstants.MILLIS_PER_SECOND); } if (iPrefix != null) { iPrefix.printTo(buf, value); } int minDigits = iMinPrintedDigits; if (minDigits <= 1) { FormatUtils.appendUnpaddedInteger(buf, value); } else { FormatUtils.appendPaddedInteger(buf, value, minDigits); } if (iFieldType >= SECONDS_MILLIS) { int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND); if (iFieldType == SECONDS_MILLIS || dp > 0) { buf.append('.'); FormatUtils.appendPaddedInteger(buf, dp, 3); } } if (iSuffix != null) { iSuffix.printTo(buf, value); } }
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) { if (partial.isSupported(iFieldType)) { try { FormatUtils.appendUnpaddedInteger(buf, partial.get(iFieldType)); } catch (RuntimeException e) { buf.append('\ufffd'); } } else { buf.append('\ufffd'); } }