IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> Java8的日期时间API LocalDate LocalTime LocalDateTime Period... Introduction to the Java 8 Date/Time API -> 正文阅读

[Java知识库]Java8的日期时间API LocalDate LocalTime LocalDateTime Period... Introduction to the Java 8 Date/Time API

原文链接:Introduction to the Java 8 Date/Time API

1. Overview 概述

Java 8 introduced new APIs for?Date?and?Time?to address the shortcomings of the older?java.util.Date?and?java.util.Calendar.

Java8引入了新的日期时间API向旧的 java.util.Date 和 java.util.Calendar 挑衅、讨伐。

In this tutorial, let's start with the issues in the existing?Date?and?Calendar?APIs and discuss how the new Java 8?Date?and?Time?APIs address them.

在这篇文章中,让我们一起先讨论下旧的日期日历APIs,之后围观下Java8中新的日期时间APIs是如何向旧社会挑战的。

We will also look at some of the core classes of the new Java 8 project that are part of the?java.time?package, such as?LocalDate,?LocalTime,?LocalDateTime,?ZonedDateTime,?Period,?Duration?and their supported APIs.

我们也会聚焦于Java8中的 java.time 类包和其中的一些主要类,如 LocalDate LocalDateTime, ZonedDateTime Period Duration 和这些类中的APIs。

?

?

?

2. Java8之前的日期API的潜在问题 Issues With the Existing?Date/Time?APIs

  • Thread safety?– The?Date?and?Calendar?classes are not thread safe, leaving developers to deal with the headache of hard-to-debug concurrency issues and to write additional code to handle thread safety. On the contrary, the new?Date?and?Time?APIs introduced in Java 8 are immutable and thread safe, thus taking that concurrency headache away from developers.

? ? ? ? 线程安全问题:java.util.Date 和 java.util.Calendar 不是线程安全的,它俩让开发人员来处理既头疼又很难调试的线程同步问题,为此还要去编写额外的代码来保证线程安全。

  • API design and ease of understanding?– The?Date?and?Calendar?APIs are poorly designed with inadequate methods to perform day-to-day operations. The new?Date/Time?API is ISO-centric and follows consistent domain models for date, time, duration and periods. There are a wide variety of utility methods that support the most common operations.
  • ZonedDate?and?Time?– Developers had to write additional logic to handle time-zone logic with the old APIs, whereas with the new APIs, handling of time zone can be done with?Local?and?ZonedDate/Time?APIs.

《未完待续》

  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2021-08-15 15:22:28  更:2021-08-15 15:25:17 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/20 8:23:38-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码