本文整理匯總了Java中org.joda.time.format.DateTimeFormatterBuilder.appendMonthOfYearShortText方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeFormatterBuilder.appendMonthOfYearShortText方法的具體用法?Java DateTimeFormatterBuilder.appendMonthOfYearShortText怎麽用?Java DateTimeFormatterBuilder.appendMonthOfYearShortText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.format.DateTimeFormatterBuilder
的用法示例。
在下文中一共展示了DateTimeFormatterBuilder.appendMonthOfYearShortText方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPeriodShortTitle
import org.joda.time.format.DateTimeFormatterBuilder; //導入方法依賴的package包/類
public static String getPeriodShortTitle(Context context, int type, long start, long end) {
final String result;
switch (type) {
case TYPE_DAY:
result = DateUtils.formatDateTime(context, start, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH);
break;
case TYPE_WEEK:
result = DateUtils.formatDateRange(context, start, end, DateUtils.FORMAT_ABBREV_MONTH);
break;
case TYPE_MONTH:
final DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
builder.appendMonthOfYearShortText();
if (new DateTime(System.currentTimeMillis()).year().get() != new DateTime(start).year().get())
builder.appendLiteral(' ').appendTwoDigitYear(2);
result = builder.toFormatter().print(start);
break;
case TYPE_YEAR:
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(start);
result = String.valueOf(c.get(Calendar.YEAR));
break;
case TYPE_CUSTOM:
if (start == 0 && end == 0)
result = "? - ?";
else if (start > 0 && end > 0)
result = DateUtils.formatDateRange(context, start, end, DateUtils.FORMAT_ABBREV_MONTH);
else if (start > 0)
result = DateTimeFormat.mediumDate().print(start) + " - ?";
else
result = "? - " + DateTimeFormat.mediumDate().print(start);
break;
default:
result = "?";
break;
}
return result;
}