We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 自定义格式化: DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); System.out.println(dtf.format(LocalDateTime.now())); //2020/09/08 21:04:12 LocalDateTime dt2 = LocalDateTime.parse("2019/11/30 05:16:17", dtf); System.out.println(dt2); //2019-11-30T05:16:17 LocalDateTime dt2 = LocalDateTime.parse("2019/11/30 5:16:17", dtf); // 时间格式异常 org.joda.time.format.DateTimeFormatter pattern = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss"); DateTime dateTime = pattern.parseDateTime("2019/11/30 5:16:17"); System.out.println(dateTime.getZone()); //Asia/Shanghai System.out.println(dateTime); //2019-11-30T05:16:17.000+08:00 System.out.println(dateTime.toString("yyyy/MM/dd HH:mm:ss.SSS")); //2019/11/30 05:16:17.000 org.joda.time.format.DateTimeFormatter pattern1 = DateTimeFormat.forPattern("HH:mm:ss"); DateTime dateTime1 = pattern1.parseDateTime("5:16:17"); System.out.println(dateTime1); //1970-01-01T05:16:17.000+08:00
DateTime.parse("2019/11/30 5:16:17"); //2020/9/8 5:16:17 DateTime.parse("2019/11/30 05:16:17"); //2020/9/8 5:16:17 DateTime.Parse("5:16:17");// c#的默认日期是当天,java joda datetime默认日期是 1970-01-01 //2020/9/8 5:16:17 DateTime.ToString(); //不提供输出格式时,序列化格式是按照当前线程的Culture里配置的格式。 //通过修改windows的时间格式,改变展示
The text was updated successfully, but these errors were encountered:
No branches or pull requests
java
c#
The text was updated successfully, but these errors were encountered: