Java有一个很好的日期解析器吗? [英] Is there a good date parser for Java?
问题描述
例如
- 如果我没有进入年月),那么应该使用当年。
- 如果年份为08,那么不应该解析0008,因为当前年份模式有4位数。
编辑:我想解析用户的输入。例如,如果用户的区域设置日期格式为dd.mm.yyyy,用户类型仅为12.11。那么解析器应该接受这个值为有效日期,值为12.11.2008。目标是一个很好的可用性。
检查Joda时间及其怪异格式化。 http://joda-time.sourceforge.net/userguide.html#Input_and_Output
Java 8包括JSR-310 ,这样也可以是一个解决方案。
Does anyone know a good date parser for different languages/locales. The built-in parser of Java (SimpleDateFormat) is very strict. It should complete missing parts with the current date.
For example
- if I do not enter the year (only day and month) then the current year should be used.
- if the year is 08 then it should not parse 0008 because the current year pattern has 4 digits.
Edit: I want to parse the input from a user. For example if the locale date format of the user is "dd.mm.yyyy" and the user type only "12.11." then the parser should accept this as a valid date with the value "12.11.2008". The target is a good usability.
Check Joda Time, and its Freaky Formatters. http://joda-time.sourceforge.net/userguide.html#Input_and_Output
Java 8 includes JSR-310 so that could be a solution as well.
这篇关于Java有一个很好的日期解析器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!