Java日期区域格式至简单格式
是否可以在Java(可能ISO 8601)中转换这种格式>哪个是字符串,以日期或时间类型的类别的“ yyyy-mm-dd”为字符串,还是应该使用字符串方法完成?
例子:
you receive this -> "2022-11-11T00:00:00"
you convert to this -> "2022-11-11"
is it possible to convert this kind of format in Java (probably ISO 8601) "2022-11-11T00:00:00" or this "2022-11-11T12:00:00+01:00"
which comes as a string, to simple format "yyyy-mm-dd" with Date or Time kind of classes, or it should be done with string methods?
Example:
you receive this -> "2022-11-11T00:00:00"
you convert to this -> "2022-11-11"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
推荐方法:
java.time
如果您需要根据值计算任何内容,或者可能会发现一周中的一天,则最好使用
java.Time
: 不建议使用此示例的输出
,但可能会出现:
字符串
操纵如果您只需要
String
s的10个字符您可以简单地采用前10个字符:
此行将存储
“ 2022-11-11”
在tobeforwarded 。
Recommended way:
java.time
If you need to calculate anything based on the values or maybe find out the day of week, you will be best adviced using
java.time
:The output of this example is
Not recommended, but possible:
String
manipulationIf you just have to
String
s you receiveyou could simply take the first 10 characters:
This line would store
"2022-11-11"
intoBeForwarded
.