java am pm_Java Calendar.AM_PM属性代码示例

/**

* Gets the text for the specified chrono, field, locale and style

* for the purpose of formatting.

*

* The text associated with the value is returned.

* The null return value should be used if there is no applicable text, or

* if the text would be a numeric representation of the value.

*

* @param chrono the Chronology to get text for, not null

* @param field the field to get text for, not null

* @param value the field value to get text for, not null

* @param style the style to get text for, not null

* @param locale the locale to get text for, not null

* @return the text for the field value, null if no text found

*/

public String getText(Chronology chrono, TemporalField field, long value,

TextStyle style, Locale locale) {

if (chrono == IsoChronology.INSTANCE

|| !(field instanceof ChronoField)) {

return getText(field, value, style, locale);

}

int fieldIndex;

int fieldValue;

if (field == ERA) {

fieldIndex = Calendar.ERA;

if (chrono == JapaneseChronology.INSTANCE) {

if (value == -999) {

fieldValue = 0;

} else {

fieldValue = (int) value + 2;

}

} else {

fieldValue = (int) value;

}

} else if (field == MONTH_OF_YEAR) {

fieldIndex = Calendar.MONTH;

fieldValue = (int) value - 1;

} else if (field == DAY_OF_WEEK) {

fieldIndex = Calendar.DAY_OF_WEEK;

fieldValue = (int) value + 1;

if (fieldValue > 7) {

fieldValue = Calendar.SUNDAY;

}

} else if (field == AMPM_OF_DAY) {

fieldIndex = Calendar.AM_PM;

fieldValue = (int) value;

} else {

return null;

}

return CalendarDataUtility.retrieveJavaTimeFieldValueName(

chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值