TextStyle.FULL 和 TextStyle.FULL_STANDALONE 有什么区别

问题描述 投票:0回答:1

java.time.format.TextStyle
枚举有以下选项:

/**
 * Full text, typically the full description.
 * For example, day-of-week Monday might output "Monday".
 */
FULL(Calendar.LONG_FORMAT, 0),
/**
 * Full text for stand-alone use, typically the full description.
 * For example, day-of-week Monday might output "Monday".
 */
FULL_STANDALONE(Calendar.LONG_STANDALONE, 0),

我的问题是:

FULL
FULL_STANDALONE
之间有什么区别 - “for stand-alone” use 是什么意思?

java java-time
1个回答
0
投票

在 java.time.format.TextStyle 枚举中,FULLFULL_STANDALONE 的相似之处在于它们都表示星期几(或月份,或其他基于文本的字段)的完整描述。区别在于它们在实践中的使用方式。

FULL 通常用作包含其他日期或时间字段的较长格式的一部分。例如,您可能有像“EEEE, MMMM d, yyyy”这样的日期格式,其中包括完整的星期几 (FULL),后跟月份和日期。

另一方面,FULL_STANDALONE 在基于文本的字段单独显示时使用,没有任何其他上下文。在这种情况下,文本可能需要略有不同才能单独理解。例如,如果您只是单独显示星期几,如果它是较长句子的一部分,您可以使用“星期一”(FULL),但如果它显示为独立标签或标题。

© www.soinside.com 2019 - 2024. All rights reserved.