DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
//将日期和时间转成字符串
String format = dtf.format(LocalDateTime.now());
//2020年7月14日 上午10时49分01秒
System.out.println(format);

这段代码在jdk11运行会报错,把环境改为jdk8就可以了

DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withZone(ZoneId.systemDefault());
//将日期和时间转成字符串
String format = dtf.format(LocalDateTime.now());
//2020年7月14日 上午10时49分01秒
System.out.println(format);

下面代码在jdk11可以运行

Exception in thread “main“ java.time.DateTimeException: Unable to extract ZoneId from temporal相关推荐

  1. java.time.DateTimeException: Unable to extract ZoneId from temporal

    前言 在学习康师傅的JAVA视频中,发现DateTimeFormatter在高版本JDK(比如:使用JDK14)会报错 问题 java.time.DateTimeException: Unable t ...

  2. Exception in thread“main“java.lang.IllegalArgument Exception:Unsupported class file major version 58

    rt,具体的错误信息如下所示: IDEA.app/Contents/lib/idea_rt.jar=55620:/Applications/IntelliJ IDEA.app/Contents/bin ...

  3. Exception in thread main java.lang.Error: 无法解析的编译问题: 方法 main 不能声明为 static;只能在静态类型或顶级类型中才能声明静态方法

    Exception in thread "main" java.lang.Error: 无法解析的编译问题: 方法 main 不能声明为 static:只能在静态类型或顶级类型中才 ...

  4. exception in thread main java.lang.noclassdeffounderror wrong name

    不含包层次的HelloWorld.java public class HelloWorld{ public static void main(String[] args) { System.out.p ...

  5. Exception in thread main java.lang.Error: Unresolved compilation problem

    初学java,使用eclipse编译时,可能会遇到如下图所示的编译错误(Exception in thread "main" java.lang.Error: Unresolved ...

  6. list.add时报错:Exception in thread “main“ java.lang.UnsupportedOperationException

    用list.add()时报错: Exception in thread "main" java.lang.UnsupportedOperationExceptionat java. ...

  7. Exception in thread main java.lang.OutOfMemoryError: Java heap space

    在做大批量数据测试的时候,服务端初始化出现问题 测试规模,没个站2万点量测数据,整个数据超过20万,初始化过程中对量测数据初始化,按站分别初始化,但是初始化到总数据量10万的时候就会报内存溢出错误. ...

  8. Exception in thread main java.lang.IncompatibleClassChangeError: net/sf/cglib/core/DebuggingClassW

    问题: 今天在运行程序的时候报如下错误. 1. java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor 2. Exception i ...

  9. Eclipse 报 “Exception in thread main java.lang.OutOfMemoryError: Java heap space ”错误的解决办法

    Eclipse 报 "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space &qu ...

最新文章

  1. 在生产集群上运行topology
  2. 第一次使用VS Code时你应该知道的一切配置
  3. YaaS,we can!
  4. win7 一些快捷系统工具命令
  5. c语言中listempty函数,list_empty()和list_empty_careful()
  6. 怎么开启队友无伤_和平精英暗夜危机无敌点位送上!不仅无伤打僵尸 敌人还看不到你...
  7. win10透明任务栏_TranslucentTB打造win10透明任务栏
  8. Flex之使用DragManager实现对象拖动
  9. word20161210
  10. linux设备驱动编写_tasklet机制
  11. 全网首发:怎样制作CDKEY(0)-目录
  12. 管理新语:主管不要当传声筒,要检查、核实
  13. cl.exe is unable to create an executable file. C compiler test failed.
  14. 《疯狂的站长》读后感1
  15. cso是什么职位(企业cso是什么职位)
  16. Jmeter与搜狗输入法、百度输入法不兼容问题解决方法
  17. 用keytool生成证书
  18. VSCode通过源代码管理插件GitLens提交项目代码的过程
  19. float a=1.0f 中的“f”代表什么
  20. QQ空间点赞Jquery代码

热门文章

  1. 音乐剧推荐-<<爱在思念的两端>>
  2. 云效安全那些事儿-Codeup代码智能安全检测服务
  3. BorderStyle short usage
  4. php api 接口
  5. 2015年09月29日
  6. 【GANs学习笔记】(二十四)StyleGAN
  7. 计算识别率的matlab代码,基于MATLAB神经网络图像识别的高识别率代码
  8. sin cos 查表法算法解析
  9. linux如何使用sin函数,Ubuntu下使用make编译c文件,不能调用sin cos 等函数问题的解决...
  10. 制作一个属于自己的BHO吧!(C#)