Refactor some duplicate code.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1406122 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4cdb63d6c0
commit
8fc7c1fe06
|
@ -394,19 +394,28 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public String format(long millis) {
|
||||
Calendar c = new GregorianCalendar(mTimeZone, mLocale); // hard code GregorianCalendar
|
||||
Calendar c = newCalendar(); // hard code GregorianCalendar
|
||||
c.setTimeInMillis(millis);
|
||||
return applyRulesToString(c);
|
||||
}
|
||||
|
||||
private String applyRulesToString(Calendar c) {
|
||||
return applyRules(c, new StringBuffer(mMaxLengthEstimate)).toString();
|
||||
}
|
||||
|
||||
private GregorianCalendar newCalendar() {
|
||||
// hard code GregorianCalendar
|
||||
return new GregorianCalendar(mTimeZone, mLocale);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.commons.lang3.time.DatePrinter#format(java.util.Date)
|
||||
*/
|
||||
@Override
|
||||
public String format(Date date) {
|
||||
Calendar c = new GregorianCalendar(mTimeZone, mLocale); // hard code GregorianCalendar
|
||||
Calendar c = newCalendar(); // hard code GregorianCalendar
|
||||
c.setTime(date);
|
||||
return applyRules(c, new StringBuffer(mMaxLengthEstimate)).toString();
|
||||
return applyRulesToString(c);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -430,7 +439,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer buf) {
|
||||
Calendar c = new GregorianCalendar(mTimeZone, mLocale); // hard code GregorianCalendar
|
||||
Calendar c = newCalendar(); // hard code GregorianCalendar
|
||||
c.setTime(date);
|
||||
return applyRules(c, buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue