gpt4 book ai didi

java - 带 [20th] 后缀的日期格式

转载 作者:行者123 更新时间:2023-12-01 13:47:24 25 4
gpt4 key购买 nike

如何将 yyyy-MM-dd hh:mm:ss 格式转换为 November, 20th 2013. 格式以供显示?

谢谢。

最佳答案

你需要这个实用方法来附加thnd,我没有写它,我从某个地方复制到我的代码中(现在不记得了):

public class NumberUtils {
public static String ordinal(int i) {
String[] sufixes = new String[] { "th", "st", "nd", "rd", "th", "th",
"th", "th", "th", "th" };
switch (i % 100) {
case 11:
case 12:
case 13:
return i + "th";
default:
return i + sufixes[i % 10];
}
}
}

将其与其他答案结合起来以获得所需的结果。

关于java - 带 [20th] 后缀的日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20258569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com