LocalDateTime 字符串与时间戳的相互转换

主要介绍LocalDateTime的格式化字符串与时间戳的相互转换

常见带日期时间格式:

字段名字段值
api格式DateTimeFormatter.ISO_LOCAL_DATE_TIME
字符串patternyyyy-MM-dd’T’HH:mm:ss.SSS’
示例2022-06-15T22:06:29.483
字符串patternyyyy-MM-dd HH:mm:ss
示例2022-06-15 22:06:29

1. 使用默认格式和默认时区

package com.ysx.utils.datetime;import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;/*** LocalDateTime 字符串与时间戳的相互转换** @author youngbear* @email youngbear@aliyun.com* @date 2024-07-07 11:38* @blog <a href="https://blog.csdn.net/next_second">...</a>* @github <a href="https://github.com/YoungBear">...</a>* @description*/
public class LocalDateTimeFormatterUtils {/*** 默认时间日期格式字符串* yyyy-MM-dd HH:mm:ss* eg.* 2022-06-15 22:06:29*/private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");/*** 根据时间戳格式化为字符串* 指定格式的时间日期格式* 使用系统默认时区** @param timestamp 时间戳 毫秒 如 1655301989483L* @return 格式化后的字符串 如 2022-06-15T22:06:29.483*/public static String long2String(long timestamp) {return Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDateTime().format(DEFAULT_FORMATTER);}/*** 根据字符串解析时间戳* 默认格式的时间日期格式* 默认时区** @param dateString 格式化后的字符串 如 2022-06-15T17:06:29.483* @return 时间戳 毫秒 如 1655301989483L*/public static long string2long(String dateString) {return LocalDateTime.parse(dateString, DEFAULT_FORMATTER).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();}}

对应单元测试

package com.ysx.utils.datetime;import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;import java.time.ZoneId;
import java.time.format.DateTimeFormatter;import static org.junit.jupiter.api.Assertions.assertEquals;/*** @author youngbear* @email youngbear@aliyun.com* @date 2024-07-07 11:55* @blog <a href="https://blog.csdn.net/next_second">...</a>* @github <a href="https://github.com/YoungBear">...</a>* @description unit test for {@link LocalDateTimeFormatterUtils}*/
public class LocalDateTimeFormatterUtilsTest {@Test@DisplayName("根据时间戳格式化为字符串 默认格式 默认时区")public void long2StringTest1() {long timestamp = 1655301989483L;ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals("2022-06-15 22:06:29", LocalDateTimeFormatterUtils.long2String(timestamp));}}@Test@DisplayName("根据字符串解析为时间戳 默认格式 默认时区")public void string2longTest1() {ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals(1655301989000L, LocalDateTimeFormatterUtils.string2long("2022-06-15 22:06:29"));}}}

2. 更多方法(指定格式和指定时区)

package com.ysx.utils.datetime;import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;/*** LocalDateTime 字符串与时间戳的相互转换** @author youngbear* @email youngbear@aliyun.com* @date 2024-07-07 11:38* @blog <a href="https://blog.csdn.net/next_second">...</a>* @github <a href="https://github.com/YoungBear">...</a>* @description*/
public class LocalDateTimeFormatterUtils {/*** 默认时间日期格式字符串* yyyy-MM-dd HH:mm:ss* eg.* 2022-06-15 22:06:29*/private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");/*** 根据时间戳格式化为字符串* 指定格式的时间日期格式* 使用系统默认时区** @param timestamp 时间戳 毫秒 如 1655301989483L* @return 格式化后的字符串 如 2022-06-15T22:06:29.483*/public static String long2String(long timestamp) {return Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDateTime().format(DEFAULT_FORMATTER);}/*** 根据时间戳格式化为字符串* 指定格式的时间日期格式* 使用系统默认时区** @param timestamp 时间戳 毫秒 如 1655301989483L* @param formatter formatter 如 DateTimeFormatter.ISO_LOCAL_DATE_TIME* @return 格式化后的字符串 如 2022-06-15T17:06:29.483*/public static String long2String(long timestamp, DateTimeFormatter formatter) {return Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter);}/*** 根据时间戳格式化为字符串* 默认格式的时间日期格式* 指定时区** @param timestamp 时间戳 毫秒 如 1655301989483L* @param zoneId 时区信息 如 ZoneId.of("Europe/Moscow")* @return 格式化后的字符串 如 2022-06-15T17:06:29.483*/public static String long2String(long timestamp, ZoneId zoneId) {return Instant.ofEpochMilli(timestamp).atZone(zoneId).toLocalDateTime().format(DEFAULT_FORMATTER);}/*** 根据时间戳格式化为字符串* 指定格式的时间日期格式* 指定时区** @param timestamp 时间戳 毫秒 如 1655301989483L* @param formatter formatter 如 DateTimeFormatter.ISO_LOCAL_DATE_TIME* @param zoneId 时区信息 如 ZoneId.of("Europe/Moscow")* @return 格式化后的字符串 如 2022-06-15T17:06:29.483*/public static String long2String(long timestamp, DateTimeFormatter formatter, ZoneId zoneId) {return Instant.ofEpochMilli(timestamp).atZone(zoneId).toLocalDateTime().format(formatter);}/*** 根据字符串解析时间戳* 默认格式的时间日期格式* 默认时区** @param dateString 格式化后的字符串 如 2022-06-15T17:06:29.483* @return 时间戳 毫秒 如 1655301989483L*/public static long string2long(String dateString) {return LocalDateTime.parse(dateString, DEFAULT_FORMATTER).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();}/*** 根据字符串解析时间戳* 指定格式的时间日期格式* 默认时区** @param dateString 格式化后的字符串 如 2022-06-15T17:06:29.483* @param formatter formatter 如 DateTimeFormatter.ISO_LOCAL_DATE_TIME* @return 时间戳 毫秒 如 1655301989483L*/public static long string2long(String dateString, DateTimeFormatter formatter) {return LocalDateTime.parse(dateString, formatter).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();}/*** 根据字符串解析时间戳* 默认格式的时间日期格式* 指定时区** @param dateString 格式化后的字符串 如 2022-06-15T17:06:29.483* @param zoneId 时区信息 如 ZoneId.of("Europe/Moscow")* @return 时间戳 毫秒 如 1655301989483L*/public static long string2long(String dateString, ZoneId zoneId) {return LocalDateTime.parse(dateString, DEFAULT_FORMATTER).atZone(zoneId).toInstant().toEpochMilli();}/*** 根据字符串解析时间戳* 指定格式的时间日期格式* 指定时区** @param dateString 格式化后的字符串 如 2022-06-15T17:06:29.483* @param formatter formatter 如 DateTimeFormatter.ISO_LOCAL_DATE_TIME* @param zoneId 时区信息 如 ZoneId.of("Europe/Moscow")* @return 时间戳 毫秒 如 1655301989483L*/public static long string2long(String dateString, DateTimeFormatter formatter, ZoneId zoneId) {return LocalDateTime.parse(dateString, formatter).atZone(zoneId).toInstant().toEpochMilli();}}

对应单元测试

package com.ysx.utils.datetime;import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;import java.time.ZoneId;
import java.time.format.DateTimeFormatter;import static org.junit.jupiter.api.Assertions.assertEquals;/*** @author youngbear* @email youngbear@aliyun.com* @date 2024-07-07 11:55* @blog <a href="https://blog.csdn.net/next_second">...</a>* @github <a href="https://github.com/YoungBear">...</a>* @description unit test for {@link LocalDateTimeFormatterUtils}*/
public class LocalDateTimeFormatterUtilsTest {@Test@DisplayName("根据时间戳格式化为字符串 默认格式 默认时区")public void long2StringTest1() {long timestamp = 1655301989483L;ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals("2022-06-15 22:06:29", LocalDateTimeFormatterUtils.long2String(timestamp));}}@Test@DisplayName("根据时间戳格式化为字符串 指定格式 默认时区")public void long2StringTest2() {long timestamp = 1655301989483L;DateTimeFormatter formatter1 = DateTimeFormatter.ISO_LOCAL_DATE_TIME;DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals("2022-06-15T22:06:29.483", LocalDateTimeFormatterUtils.long2String(timestamp, formatter1));assertEquals("2022-06-15 22:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, formatter2));}}@Test@DisplayName("根据时间戳格式化为字符串 默认格式 指定时区")public void long2StringTest3() {long timestamp = 1655301989483L;ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");ZoneId zoneIdMoscow = ZoneId.of("Europe/Moscow");ZoneId zoneIdParis = ZoneId.of("Europe/Paris");ZoneId zoneIdLos_Angeles = ZoneId.of("America/Los_Angeles");assertEquals("2022-06-15 22:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, zoneIdShanghai));assertEquals("2022-06-15 17:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, zoneIdMoscow));assertEquals("2022-06-15 16:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, zoneIdParis));assertEquals("2022-06-15 07:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, zoneIdLos_Angeles));}@Test@DisplayName("根据时间戳格式化为字符串 指定格式 指定时区")public void long2StringTest4() {long timestamp = 1655301989483L;DateTimeFormatter formatter1 = DateTimeFormatter.ISO_LOCAL_DATE_TIME;DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");ZoneId zoneIdMoscow = ZoneId.of("Europe/Moscow");ZoneId zoneIdParis = ZoneId.of("Europe/Paris");ZoneId zoneIdLos_Angeles = ZoneId.of("America/Los_Angeles");assertEquals("2022-06-15T22:06:29.483", LocalDateTimeFormatterUtils.long2String(timestamp, formatter1, zoneIdShanghai));assertEquals("2022-06-15T17:06:29.483", LocalDateTimeFormatterUtils.long2String(timestamp, formatter1, zoneIdMoscow));assertEquals("2022-06-15T16:06:29.483", LocalDateTimeFormatterUtils.long2String(timestamp, formatter1, zoneIdParis));assertEquals("2022-06-15T07:06:29.483", LocalDateTimeFormatterUtils.long2String(timestamp, formatter1, zoneIdLos_Angeles));assertEquals("2022-06-15 22:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, formatter2, zoneIdShanghai));assertEquals("2022-06-15 17:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, formatter2, zoneIdMoscow));assertEquals("2022-06-15 16:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, formatter2, zoneIdParis));assertEquals("2022-06-15 07:06:29", LocalDateTimeFormatterUtils.long2String(timestamp, formatter2, zoneIdLos_Angeles));}@Test@DisplayName("根据字符串解析为时间戳 默认格式 默认时区")public void string2longTest1() {ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals(1655301989000L, LocalDateTimeFormatterUtils.string2long("2022-06-15 22:06:29"));}}@Test@DisplayName("根据字符串解析为时间戳 指定格式 默认时区")public void string2longTest2() {DateTimeFormatter formatter1 = DateTimeFormatter.ISO_LOCAL_DATE_TIME;DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");long timestamp1 = 1655301989483L;long timestamp2 = 1655301989000L;String dateStringShanghai1 = "2022-06-15T22:06:29.483";String dateStringShanghai2 = "2022-06-15 22:06:29";try (MockedStatic<ZoneId> mockedZonedId = Mockito.mockStatic(ZoneId.class)) {mockedZonedId.when(ZoneId::systemDefault).thenReturn(zoneIdShanghai);assertEquals(timestamp1, LocalDateTimeFormatterUtils.string2long(dateStringShanghai1, formatter1));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringShanghai2, formatter2));}}@Test@DisplayName("根据字符串解析为时间戳 默认格式 指定时区")public void string2longTest3() {ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");ZoneId zoneIdMoscow = ZoneId.of("Europe/Moscow");ZoneId zoneIdParis = ZoneId.of("Europe/Paris");ZoneId zoneIdLos_Angeles = ZoneId.of("America/Los_Angeles");String dateStringShanghai2 = "2022-06-15 22:06:29";String dateStringMoscow2 = "2022-06-15 17:06:29";String dateStringParis2 = "2022-06-15 16:06:29";String dateStringLos_Angeles2 = "2022-06-15 07:06:29";long timestamp2 = 1655301989000L;assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringShanghai2, zoneIdShanghai));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringMoscow2, zoneIdMoscow));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringParis2, zoneIdParis));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringLos_Angeles2, zoneIdLos_Angeles));}@Test@DisplayName("根据字符串解析为时间戳 指定格式 指定时区")public void string2longTest4() {DateTimeFormatter formatter1 = DateTimeFormatter.ISO_LOCAL_DATE_TIME;DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");ZoneId zoneIdMoscow = ZoneId.of("Europe/Moscow");ZoneId zoneIdParis = ZoneId.of("Europe/Paris");ZoneId zoneIdLos_Angeles = ZoneId.of("America/Los_Angeles");String dateStringShanghai1 = "2022-06-15T22:06:29.483";String dateStringMoscow1 = "2022-06-15T17:06:29.483";String dateStringParis1 = "2022-06-15T16:06:29.483";String dateStringLos_Angeles1 = "2022-06-15T07:06:29.483";String dateStringShanghai2 = "2022-06-15 22:06:29";String dateStringMoscow2 = "2022-06-15 17:06:29";String dateStringParis2 = "2022-06-15 16:06:29";String dateStringLos_Angeles2 = "2022-06-15 07:06:29";long timestamp1 = 1655301989483L;long timestamp2 = 1655301989000L;assertEquals(timestamp1, LocalDateTimeFormatterUtils.string2long(dateStringShanghai1, formatter1, zoneIdShanghai));assertEquals(timestamp1, LocalDateTimeFormatterUtils.string2long(dateStringMoscow1, formatter1, zoneIdMoscow));assertEquals(timestamp1, LocalDateTimeFormatterUtils.string2long(dateStringParis1, formatter1, zoneIdParis));assertEquals(timestamp1, LocalDateTimeFormatterUtils.string2long(dateStringLos_Angeles1, formatter1, zoneIdLos_Angeles));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringShanghai2, formatter2, zoneIdShanghai));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringMoscow2, formatter2, zoneIdMoscow));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringParis2, formatter2, zoneIdParis));assertEquals(timestamp2, LocalDateTimeFormatterUtils.string2long(dateStringLos_Angeles2, formatter2, zoneIdLos_Angeles));}
}

源码地址-github

源码地址-gitee

更多文章

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/867804.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Golang | Leetcode Golang题解之第213题打家劫舍II

题目&#xff1a; 题解&#xff1a; func _rob(nums []int) int {first, second : nums[0], max(nums[0], nums[1])for _, v : range nums[2:] {first, second second, max(firstv, second)}return second }func rob(nums []int) int {n : len(nums)if n 1 {return nums[0]}…

SSRF靶场通关合集

目录 前言 SSRF总结 1.pikachu 1.1SSRF(curl) 1.1.1http协议 1.1.2 file协议查看本地文件 1.1.3 dict协议扫描内网主机开放端口 1.2 SSRF&#xff08;file_get_content&#xff09; 1.2.1 file读取本地文件 1.2.2 php://filter/读php源代码 2.DoraBox靶场 前言 最近…

恢复出厂设置手机变成砖

上周&#xff0c;许多Google Pixel 6&#xff08;6、6a、6 Pro&#xff09;手机用户在恢复出厂设置后都面临着设备冻结的问题。 用户说他们在下载过程中遇到了丢失 tune2fs 文件的错误 。 这会导致屏幕显示以下消息&#xff1a;“Android 系统无法启动。您的数据可能会被损坏…

Linux服务器使用总结-不定时更新

# 查看升级日志 cat /var/log/dpkg.log |grep nvidia|grep libnvidia-common

如何在多个服务器上安装WordPress分布式部署

许多网络主机现在保证其服务的正常运行时间为 99.9%&#xff0c;但这仍然每年最多有 8.7 小时的停机时间。 许多公司不能够承担这种风险。例如。在超级碗比赛中失败的体育新闻网站可能会失去忠实的追随者。 我们通过设置维护高可用性 WordPress分布式部署配置来帮助 WordPres…

unity3d:Shader知识点,矩阵,函数,坐标转换,Tags,半透明,阴影,深度,亮度,优化

基本结构 Shader "MyShaderName" {Properties {// 属性}SubShader {// 针对显卡A的SubShaderPass {// 设置渲染状态和标签Tags { "LightMode""ForwardBase" }// 开始Cg代码片段CGPROGRAM// 该代码片段的编译指令&#xff0c;例如&#xff1a;#p…

【笔记】在window上连接虚拟机中的redis

愚昧啊 困扰了我近两天的问题居然是因为是java代码写错地方了 在虚拟机中进入redis.conf文件 vim redis.conf /bind --斜杠搜索关键词 将值设置为 bind 0.0.0.0 保存 退出:wq 回到java中 添加redis依赖 刷新maven 就是在这一步出问题……………………………………自己在蓝…

LeetCode 189.轮转数组 三段逆置 C写法

LeetCode 189.轮转数组 C写法 三段逆置 思路: 三段逆置方法:先逆置前n-k个 再逆置后k个 最后整体逆置 由示例1得&#xff0c;需要先逆置1,2,3,4 再逆置5,6,7&#xff0c;最后前n-k个与后k个逆置 代码 void reverse(int*num, int left, int right) //逆置函数 { while(left …

react-类组件1

类组件&#xff1a; import { Component } from "react";class App extends Component {constructor() {super();this.state {message: "xxxxx",};}render() {return (<div><div>{this.state.message}</div></div>);} }export d…

算法的空间复杂度(C语言)

1.空间复杂度的定义 算法在临时占用储存空间大小的量度&#xff08;就是完成这个算法所额外开辟的空间&#xff09;&#xff0c;空间复杂度也使用大O渐进表示法来表示 注&#xff1a; 函数在运行时所需要的栈空间(储存参数&#xff0c;局部变量&#xff0c;一些寄存器信息等)…

Python | Leetcode Python题解之第217题存在重复元素

题目&#xff1a; 题解&#xff1a; class Solution(object):def containsDuplicate(self, nums):if len(set(nums)) ! len(nums):return Trueelse:return False

一种一维时间序列信号变化/事件/异常检测方法(MATLAB)

随着工业物联网、大数据和人工智能的发展&#xff0c;传统工业正在向数字化和智能化升级&#xff0c;从而创造了大量的时间序列数据。通过分析这些数据&#xff0c;可以提供准确可靠的信息服务和决策依据&#xff0c;促进制造业的转型升级。工业物联网在传统工业向“工业 4.0”…

PostgreSQL 如何优化存储过程的执行效率?

文章目录 一、查询优化1. 正确使用索引2. 避免不必要的全表扫描3. 使用合适的连接方式4. 优化子查询 二、参数传递1. 避免传递大对象2. 参数类型匹配 三、减少数据量处理1. 限制返回结果集2. 提前筛选数据 四、优化逻辑结构1. 分解复杂的存储过程2. 避免过度使用游标 五、事务处…

合并pdf的方法,如何合并pdf文件到一个pdf,简单方法

在现代办公和学习中&#xff0c;pdf格式的文件因其跨平台兼容性和安全性得到了广泛应用。然而&#xff0c;有时我们需要将多个pdf文件合并成一个&#xff0c;以便于管理和分享。本文将详细介绍几种合并pdf的方法&#xff0c;帮助读者轻松完成pdf文件的合并工作。 方法一、使用p…

Camera Raw:编辑 - 校准

Camera Raw “编辑”模块中的校准 Calibration面板设计初衷是校准相机所采集的 R、G、B 色彩信息&#xff0c;使相机的 RGB 色域范围尽可能与标准 RGB 色域范围重合。不过&#xff0c;现在多用于创意调色。通过调整红、绿、蓝三个原色的色相和饱和度&#xff0c;以及阴影的色调…

cs231n 作业3

使用普通RNN进行图像标注 单个RNN神经元行为 前向传播&#xff1a; 反向传播&#xff1a; def rnn_step_backward(dnext_h, cache):dx, dprev_h, dWx, dWh, db None, None, None, None, Nonex, Wx, Wh, prev_h, next_h cachedtanh 1 - next_h**2dx (dnext_h*dtanh).dot(…

《华为战略管理法:DSTE实战体系》累计印量已达4万册(截至2024年7月)

近日&#xff0c;从中国人民大学出版社丁一老师处获悉&#xff0c;截至2024年07月&#xff0c;谢宁老师专著《华为战略管理法:DSTE实战体系》已经完成第10次印刷&#xff0c;累计4万册。&#xff08;该书于2022年06月份出版&#xff09;。 《华为战略管理法:DSTE实战体系》作为…

Linux——进程间通信一(共享内存、管道、systrem V)

一、进程间通信介绍 1.1、进程间通信的概念和意义 进程间通信(IPC interprocess communication)是一组编程接口&#xff0c;让不同进程之间相互传递、交换信息(让不同的进程看到同一份资源) 数据传输:一个进程需要将它的数据发送给另外一个进程 资源共享:多个进程之间共享同样…

fork创建子进程详解

一.前言 在上一篇文章-进程的概念&#xff0c;最后我们提到了创建进程的方式有两种方式&#xff0c;一种是手动的创建出进程&#xff0c;还有一种就是我们今天要学习的使用代码的方式创建出子进程-fork。 而学习fork创建出进程的过程中&#xff0c;我们会遇到以下问题&#x…

ECharts在最新版本中使用getInstanceByDom报错处理

引用问题导致报错 如果按如下引用的话&#xff0c;会报错 import echarts from “echarts/lib/echarts”; 原因 在 ECharts 的之前版本中&#xff0c;默认导出了一个名为 echarts 的对象&#xff0c;所以使用 import echarts from “echarts” 是没有问题的。但是在 ECharts …