如何将Joda LocalDate转换为Java中的String? [英] How to convert Joda LocalDate to String in Java?
本文介绍了如何将Joda LocalDate转换为Java中的String?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到答案:
这很简单。
I got the answer: It's very simple.
DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy");
String formattedDate = jodeLocalDateObj.toString( fmt );
推荐答案
LocalDate的 toString
可以直接使用格式字符串,因此您可以跳过创建DateTimeFormatter:
LocalDate's toString
can take a format string directly, so you can skip creating the DateTimeFormatter:
String formattedDate = myLocalDate.toString("MM/dd/yyyy");
http://joda-time.sourceforge.net/apidocs/org/joda/time/LocalDate.html#toString(java .lang.String)
我也在我的博客上写了一篇关于它的帖子 - http://codetutr.com/2013/03/05/joda-time-how -to-parse-a-string-to-joda-localdate /
I also wrote a post about it on my blog - http://codetutr.com/2013/03/05/joda-time-how-to-parse-a-string-to-joda-localdate/
这篇关于如何将Joda LocalDate转换为Java中的String?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文