class FastDateFormat.NumberRule {
/**
* Appends the specified value to the output buffer based on the rule implementation.
*
* @param buffer the output buffer
* @param value the value to be appended
*/
void appendTo(StringBuffer buffer, int value);
}
class FastDateFormat.UnpaddedNumberField {
public final void appendTo(StringBuffer buffer, int value) {
if (value < 10) {
buffer.append((char)(value + '0'));
} else if (value < 100) {
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
} else {
buffer.append(Integer.toString(value));
}
}
}
class FastDateFormat.UnpaddedMonthField {
public final void appendTo(StringBuffer buffer, int value) {
if (value < 10) {
buffer.append((char)(value + '0'));
} else {
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
}
}
}
class FastDateFormat.PaddedNumberField {
public final void appendTo(StringBuffer buffer, int value) {
if (value < 100) {
for (int i = mSize; --i >= 2; ) {
buffer.append('0');
}
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
} else {
int digits;
if (value < 1000) {
digits = 3;
} else {
Validate.isTrue(value > -1, "Negative values should not be possible", value);
digits = Integer.toString(value).length();
}
for (int i = mSize; --i >= digits; ) {
buffer.append('0');
}
buffer.append(Integer.toString(value));
}
}
}
class FastDateFormat.TwoDigitNumberField {
public final void appendTo(StringBuffer buffer, int value) {
if (value < 100) {
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
} else {
buffer.append(Integer.toString(value));
}
}
}
class FastDateFormat.TwoDigitYearField {
public final void appendTo(StringBuffer buffer, int value) {
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
}
}
class FastDateFormat.TwoDigitMonthField {
public final void appendTo(StringBuffer buffer, int value) {
buffer.append((char)(value / 10 + '0'));
buffer.append((char)(value % 10 + '0'));
}
}
class FastDateFormat.TwelveHourField {
public void appendTo(StringBuffer buffer, int value) {
mRule.appendTo(buffer, value);
}
}
class FastDateFormat.TwentyFourHourField {
public void appendTo(StringBuffer buffer, int value) {
mRule.appendTo(buffer, value);
}
}
|