简体   繁体   English

用Joda-Time解析周日?

[英]Parse Week Dates with Joda-Time?

I need to parse ISO 8601 Week dates into a format that Joda-Time can hopefully work with (eg. use for calculating the days in that week, etc.) 我需要将ISO 8601周日期解析为Joda-Time可以使用的格式(例如,用于计算该周的天数等)

I've looked around a bit, but there doesn't seem to be any clear docs on how to do this. 我看了一下,但似乎没有任何关于如何做到这一点的明确文档。

A full DateTime instance isn't right, since I don't have an Instant in time, I only have a Partial . 一个完整的DateTime实例是不对的,因为我没有及时的Instant,我只有一个Partial I can't seem to find any way to parse things into a Partial , however. 但是,我似乎无法找到任何解析Partial

Do I need to write my own parse() method that can give me back a partial? 我是否需要编写自己的parse()方法,这可以让我回到局部? There seem to be a couple of built-in parse methods that do this, but they all seem very specific and don't take a general format object. 似乎有一些内置的解析方法可以做到这一点,但它们看起来都非常具体,并且不采用通用格式对象。

Specifically, I have ISO 8601 Week dates in the following forms: 具体来说,我有以下几种形式的ISO 8601周日期:

1998-W12
2005W23

What I need to do with these (ultimately) is take the week, and then convert that into a collection of the days in a given week ( LocalDate JodaTime objects specifically). 我需要做的是(最终)需要一周,然后将其转换为给定周内的日期集合(具体为LocalDate JodaTime对象)。 eg. 例如。

2013-W52 =>
2013-12-31
2014-01-01
2014-01-02
2014-01-03
2014-01-04
2014-01-05
2014-01-06

JodaTime has ISO-8601 support built in. Look at the ISODateTimeFormatter. JodaTime内置了ISO-8601支持。请查看ISODateTimeFormatter。 http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM