Java 类org.joda.time.format.FormatUtils 实例源码
项目:TinyTravelTracker
文件:AbstractDuration.java
/**
* 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();
}
项目:astor
文件:AbstractDuration.java
/**
* 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();
}
项目:astor
文件:AbstractDuration.java
/**
* 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();
}
项目:idylfin
文件:AbstractDuration.java
/**
* 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();
}
项目:versemem-android
文件:AbstractDuration.java
/**
* 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();
}
项目:TinyTravelTracker
文件:DateTimeZone.java
/**
* Formats a timezone offset string.
* <p>
* This method is kept separate from the formatting classes to speed and
* simplify startup and classloading.
*
* @param offset the offset in milliseconds
* @return the time zone string
*/
private static String printOffset(int offset) {
StringBuffer buf = new StringBuffer();
if (offset >= 0) {
buf.append('+');
} else {
buf.append('-');
offset = -offset;
}
int hours = offset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.appendPaddedInteger(buf, hours, 2);
offset -= hours * (int) DateTimeConstants.MILLIS_PER_HOUR;
int minutes = offset / DateTimeConstants.MILLIS_PER_MINUTE;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, minutes, 2);
offset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
if (offset == 0) {
return buf.toString();
}
int seconds = offset / DateTimeConstants.MILLIS_PER_SECOND;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, seconds, 2);
offset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (offset == 0) {
return buf.toString();
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, offset, 3);
return buf.toString();
}
项目:astor
文件:DateTimeZone.java
/**
* Formats a timezone offset string.
* <p>
* This method is kept separate from the formatting classes to speed and
* simplify startup and classloading.
*
* @param offset the offset in milliseconds
* @return the time zone string
*/
private static String printOffset(int offset) {
StringBuffer buf = new StringBuffer();
if (offset >= 0) {
buf.append('+');
} else {
buf.append('-');
offset = -offset;
}
int hours = offset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.appendPaddedInteger(buf, hours, 2);
offset -= hours * (int) DateTimeConstants.MILLIS_PER_HOUR;
int minutes = offset / DateTimeConstants.MILLIS_PER_MINUTE;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, minutes, 2);
offset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
if (offset == 0) {
return buf.toString();
}
int seconds = offset / DateTimeConstants.MILLIS_PER_SECOND;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, seconds, 2);
offset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (offset == 0) {
return buf.toString();
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, offset, 3);
return buf.toString();
}
项目:astor
文件:DateTimeZone.java
/**
* Formats a timezone offset string.
* <p>
* This method is kept separate from the formatting classes to speed and
* simplify startup and classloading.
*
* @param offset the offset in milliseconds
* @return the time zone string
*/
private static String printOffset(int offset) {
StringBuffer buf = new StringBuffer();
if (offset >= 0) {
buf.append('+');
} else {
buf.append('-');
offset = -offset;
}
int hours = offset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.appendPaddedInteger(buf, hours, 2);
offset -= hours * (int) DateTimeConstants.MILLIS_PER_HOUR;
int minutes = offset / DateTimeConstants.MILLIS_PER_MINUTE;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, minutes, 2);
offset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
if (offset == 0) {
return buf.toString();
}
int seconds = offset / DateTimeConstants.MILLIS_PER_SECOND;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, seconds, 2);
offset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (offset == 0) {
return buf.toString();
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, offset, 3);
return buf.toString();
}
项目:idylfin
文件:DateTimeZone.java
/**
* Formats a timezone offset string.
* <p>
* This method is kept separate from the formatting classes to speed and
* simplify startup and classloading.
*
* @param offset the offset in milliseconds
* @return the time zone string
*/
private static String printOffset(int offset) {
StringBuffer buf = new StringBuffer();
if (offset >= 0) {
buf.append('+');
} else {
buf.append('-');
offset = -offset;
}
int hours = offset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.appendPaddedInteger(buf, hours, 2);
offset -= hours * (int) DateTimeConstants.MILLIS_PER_HOUR;
int minutes = offset / DateTimeConstants.MILLIS_PER_MINUTE;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, minutes, 2);
offset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
if (offset == 0) {
return buf.toString();
}
int seconds = offset / DateTimeConstants.MILLIS_PER_SECOND;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, seconds, 2);
offset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (offset == 0) {
return buf.toString();
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, offset, 3);
return buf.toString();
}
项目:versemem-android
文件:DateTimeZone.java
/**
* Formats a timezone offset string.
* <p>
* This method is kept separate from the formatting classes to speed and
* simplify startup and classloading.
*
* @param offset the offset in milliseconds
* @return the time zone string
*/
private static String printOffset(int offset) {
StringBuffer buf = new StringBuffer();
if (offset >= 0) {
buf.append('+');
} else {
buf.append('-');
offset = -offset;
}
int hours = offset / DateTimeConstants.MILLIS_PER_HOUR;
FormatUtils.appendPaddedInteger(buf, hours, 2);
offset -= hours * (int) DateTimeConstants.MILLIS_PER_HOUR;
int minutes = offset / DateTimeConstants.MILLIS_PER_MINUTE;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, minutes, 2);
offset -= minutes * DateTimeConstants.MILLIS_PER_MINUTE;
if (offset == 0) {
return buf.toString();
}
int seconds = offset / DateTimeConstants.MILLIS_PER_SECOND;
buf.append(':');
FormatUtils.appendPaddedInteger(buf, seconds, 2);
offset -= seconds * DateTimeConstants.MILLIS_PER_SECOND;
if (offset == 0) {
return buf.toString();
}
buf.append('.');
FormatUtils.appendPaddedInteger(buf, offset, 3);
return buf.toString();
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(StringBuffer buf, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) {
int value = getValue(instant, chrono);
FormatUtils.appendPaddedInteger(buf, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(Writer out, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws
IOException {
int value = getValue(instant, chrono);
FormatUtils.writePaddedInteger(out, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) {
int value = getValue(partial);
FormatUtils.appendPaddedInteger(buf, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(Writer out, ReadablePartial partial, Locale locale) throws IOException {
int value = getValue(partial);
FormatUtils.writePaddedInteger(out, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(StringBuffer buf, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) {
int value = getValue(instant, chrono);
FormatUtils.appendPaddedInteger(buf, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(Writer out, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws
IOException {
int value = getValue(instant, chrono);
FormatUtils.writePaddedInteger(out, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(StringBuffer buf, ReadablePartial partial, Locale locale) {
int value = getValue(partial);
FormatUtils.appendPaddedInteger(buf, value, 2);
}
项目:eHMP
文件:TwoDigitNumber.java
public void printTo(Writer out, ReadablePartial partial, Locale locale) throws IOException {
int value = getValue(partial);
FormatUtils.writePaddedInteger(out, value, 2);
}