我有些不同的日期格式可以解析, 但我无法用 < code> SoperDate Format code > 来识别它们。 有人能帮我找到这个日期的模式吗 :
- 6 July 1892
- 9 May 1915
- February 335
- 1768-02-12
和
- 23 september 63 bc
- 19 august ad 14
谢谢 谢谢
我有些不同的日期格式可以解析, 但我无法用 < code> SoperDate Format code > 来识别它们。 有人能帮我找到这个日期的模式吗 :
和
谢谢 谢谢
您只是提供了模式的可能性, 您希望您的日期能够通过它们找到第一个匹配点, 并运行到它们中 。
private static DateTimeFormatter dateFormatter;
String[] validDateFormats = new String[] { "dd-MMM-yyyy HH:mm:ss",
"yyyy-MM-dd HH:mm:ss.SSS" };
DateTimeParser[] parsers = new DateTimeParser[validDateFormats.length];
for (int i = 0; i < validDateFormats.length; ++i) {
parsers[i] = DateTimeFormat.forPattern(validDateFormats[i])
.getParser();
}
dateFormatter = new DateTimeFormatterBuilder().append(null, parsers)
.toFormatter().withZone(DateTimeZone.UTC);
如果输入符合任何格式, 此日期Formatter 将会正确解析 :
inputDate = dateFormatter.parseDateTime(dateStr);
DateTimeFormatter outputFormat = DateTimeFormat
.forPattern("yyyy/MM/dd");
String outputString = inputDate.toString(outputFormat);
从这里可以查看格式字符串 : http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html
Here you can find a great generator for creating every date format you can imagine http://www.fileformat.info/tip/java/simpledateformat.htm
例如,您的第一个例子都是用 dd MMM yyyy 生成的;)
尝尝这个
2012年5月27日至2012年5月27日:
System.out.println(新的简单日期格式 (“ d- MMM- YYYYY”)).format( 新日期 () );
27-05-2012年:
System.out.println(new SimpleDateFormat("d-MM-YYYY").format(new Date()));
27-05-12:
System.out.println(new SimpleDateFormat("dd-MM-YY").format(new Date()));
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...