scala 中的 Joda Time 库返回错误的日期

发布于 2024-10-21 03:59:26 字数 325 浏览 2 评论 0原文

我在我的 scala 代码中使用 joda 时间库。我的代码如下。

val dt:DateTime = new DateTime()
val dtf:DateTimeFormatter = DateTimeFormat.forPattern("yyyy-mm-dd")
return dtf.print(dt.minusDays(1))

假设当前日期是 2011 年 3 月 11 日,上面的代码应该返回字符串 2011-03-10,但我得到的输出是 2011-52-10

是什么导致了这个问题?

请帮忙 谢谢

Im using the joda time library in my scala code. My code is as follows .

val dt:DateTime = new DateTime()
val dtf:DateTimeFormatter = DateTimeFormat.forPattern("yyyy-mm-dd")
return dtf.print(dt.minusDays(1))

Assuming the current date is March 11 2011,the above code should return the string 2011-03-10,but the output i get is 2011-52-10

What could be causing this problem ?

Please Help
Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋心╮凉 2024-10-28 03:59:26

DateTimeFormat 模式 mm 表示分钟,使用 MM 表示几个月。

In a DateTimeFormat the pattern mm is for minutes, use MM for months.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文