您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何将LocalDate格式化为字符串?

如何将LocalDate格式化为字符串?

如果他从Java 8中的新功能LocalDate开始,SimpleDateFormat将无法工作。从我所看到的,您将不得不使用DateTimeFormatter,http://docs.oracle.com/javase/8/docs/api/java/ time / format / DateTimeFormatter.html。

LocalDate localDate = LocalDate.Now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);

该日期应为1988年5月5日。要获取第二天之后和该月之前的时间,您可能必须使用“ dd’.LLLL y??yyy”

其他 2022/1/1 18:13:48 有509人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶