Java时间类--JDK8

news2024/9/23 21:27:51

为什么JDK8会又新增时间相关类呢?

 ① JDK7的时间对象如果需要比较大小的话,必须都先转换成毫秒值;JDK8则不需要,可以直接比较。

② JDK7的时间对象可以修改,在多线程环境下就会导致数据不安全;JDK8不能修改,不会发生安全问题。

JDK8时间类一共有10个类,

前3个类似于JDK7中的Date类,

第4个类似于JDK7中的 SimpleDateFormat 类,

第5~7类类似于JDK7中的 Calendar 类,

最后三个类用于计算时间间隔。

一、ZoneId时区类

1. getAvailableZoneIds方法

public class Demo {
    public static void main(String[] args) {
        //1.getAvailableZoneIds  获取所有的时区名称
        Set<String> zoneIds = ZoneId.getAvailableZoneIds();

        System.out.println(zoneIds.size());//603个时区
        System.out.println(zoneIds);
    }
}

运行结果: 

2. systemDefault方法

public class Demo {
    public static void main(String[] args) {
        //2.systemDefault  获取系统默认时区
        ZoneId zoneId = ZoneId.systemDefault();
        System.out.println(zoneId);//Asia/Shanghai
    }
}

如果想要更改系统默认时区:

① 点击系统设置

② 点击 “时间和语言”

 ③ 点击 "日期和时间" 

④ 选择时区

 比如将时区修改为 台北:

再次获取系统默认时区:

 3. of 方法

public class Demo {
    public static void main(String[] args) {
        //3.of  获取指定的时区
        ZoneId zoneId = ZoneId.of("Asia/Pontianak");
        System.out.println(zoneId);//Asia/Pontianak
    }
}

获取到时区之后就可以结合后续类进行操作了。

二、Instant时间戳类

1.now方法

public class Demo {
    public static void main(String[] args) {
        //1.now  获取当前时间的时间戳对象(标准时间)
        Instant now=Instant.now();
        System.out.println(now);
    }
}

 细节:

now方法获取的是标准时间(不含时区),如果想获得我国的时间,还要在此基础上+8h。

2. ofxxx方法

public class Demo {
    public static void main(String[] args) {
        //2.ofxxx  根据指定的(秒/毫秒/纳秒)获取时间戳对象
        Instant instant1 = Instant.ofEpochMilli(0L);//距时间原点0ms
        System.out.println(instant1);
        
        Instant instant2 = Instant.ofEpochSecond(1L);//距时间原点1s
        System.out.println(instant2);

        Instant instant3 = Instant.ofEpochSecond(1L, 1000000000L);
        //距时间原点1s + 10^9ns = 2s
        System.out.println(instant3);
        
    }
}

运行结果: 

细节:

用ofxxx方法获取指定时间的时间戳对象,是不带时区的

3.atZone方法

public class Demo {
    public static void main(String[] args) {
        //3.atZone  获取指定时区的时间戳对象
        ZonedDateTime time = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(time);
    }
}

运行结果:

细节:

atZone方法不是静态方法,不能通过类名调用,需要通过 对象名.方法名 调用。

4.isxxx方法

public class Demo {
    public static void main(String[] args) {
        //4.isxxx 用于时间的判断
        Instant instant1 = Instant.ofEpochMilli(0L);
        Instant instant2 = Instant.ofEpochMilli(1000L);

        //isbefore  判断调用者(instant1)代表的时间是否在参数(instant2)代表的时间之前
        boolean result1 = instant1.isBefore(instant2);
        System.out.println(result1);//true

        //isAfter  判断调用者(instant1)代表的时间是否在参数(instant2)代表的时间之前之后
        boolean result2 = instant1.isAfter(instant2);
        System.out.println(result2);//false
    }
}

细节:

使用isxxx方法无需将时间转换成毫秒值,就可以直接对两个时间对象进行比较了。

5.minusxxx方法和plusxxx方法

public class Demo {
    public static void main(String[] args) {
        //5.minusxxx  减少时间
        Instant instant1 = Instant.ofEpochMilli(3000L);
        System.out.println(instant1);//1970-01-01T00:00:03Z

        //minusSeconds:减少xx秒
        //minusMillis:减少xx毫秒
        //minusNanos:减少xx纳秒
        Instant instant2 = instant1.minusSeconds(1L);
        System.out.println(instant2);//1970-01-01T00:00:02Z
        
        //6.plusxxx  增加时间(方法和minusxxx同理)
        Instant instant3=instant1.plusSeconds(1L);
        System.out.println(instant3);//1970-01-01T00:00:04Z
    }
}

细节:

JDK8之后,创建的时间对象是不可能发生改变的。

所以,增加/减少后,原有时间对象并没有改变,而是创建了一个新的时间对象。

三、ZoneDateTime带时区的时间类

1.now方法和of方法

public class Demo {
    public static void main(String[] args) {
        //1.now  获取当前的时间对象(带时区)
        ZonedDateTime now = ZonedDateTime.now();
        System.out.println(now);

        //2.of  获取指定的时间对象(带时区)
        //① 指定方式一 --> 年,月,日,时,分,秒,纳秒,时区
        ZonedDateTime time1 = ZonedDateTime.of(2024, 5, 20,
                13, 14, 20, 0, ZoneId.of("Asia/Shanghai"));
        System.out.println(time1);

        //② 指定方式二 --> Instant + 时区
        Instant instant = Instant.ofEpochMilli(0L);
        ZoneId zoneId = ZoneId.of("Asia/Shanghai");
        ZonedDateTime time2 = ZonedDateTime.ofInstant(instant, zoneId);
        System.out.println(time2);
    }
}

运行结果:

细节:

① 通过运行结果可以看出,ZonedDateTime类创建的时间对象是带时区的

② of 方法有两种指定方式:

一种是        年,月,日,时,分,秒,纳秒,时区

另一种是     Instant + 时区

2.withxxx方法、minusxxx方法和plusxxx方法

public class Demo {
    public static void main(String[] args) {
        Instant instant = Instant.ofEpochMilli(0L);
        ZoneId zoneId = ZoneId.of("Asia/Shanghai");
        ZonedDateTime time1 = ZonedDateTime.ofInstant(instant, zoneId);
        System.out.println("time1:"+time1);

        //3.withxxx  修改时间
        ZonedDateTime time2 = time1.withYear(2000);
        System.out.println("time2:"+time2);

        //4.minusxxx  减少时间
        ZonedDateTime time3 = time2.minusYears(1);
        System.out.println("time3:"+time3);

        //5.plusxxx  增加时间
        ZonedDateTime time4 = time3.plusYears(1);
        System.out.println("time4:"+time4);
    }
}

 细节:

无论是修改,减少还是增加时间,都没有修改原有的时间对象,而是创建了一个新的对象

② 修改,减少,增加都有很多的方法,可以修改各种各样的时间,如下:

四、DateTimeFormatter类

public class Demo {
    public static void main(String[] args) {
        //获取时间对象
        ZonedDateTime time= Instant.now().atZone(ZoneId.of("Asia/Shanghai"));

        //1.ofPattern  获取格式对象
        DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss EE a");

        //2.format  按照指定方式格式化
        String str= dtf.format(time);
        System.out.println(str);//2024-05-26 21:36:06 周日 下午

    }
}

细节:

DateTimeFormatter 类和 SimpleDateFormat 类一样,都是用于时间的格式化和解析。

但:

DateTimeFormatter 类是不可变的,一旦创建就不可更改。

SimpleDateFormat 类是可变的,可以通过方法调用更改其状态。

所以 DateTimeFormatter 类也解决了因为多线程环境而造成的安全性问题

五、LocalDate类、LocalTime类和LocalDateTime类

该3个类类似于JDK7中的 Calendar 类,使用方法也极其相似。

可以获得时间(日历)对象,取出某个字段值,或者修改、减少/增加某个字段值。

除此之外,LocalDateTime 对象还可以转换成 LocalDate 对象和 LocalTime 对象

 1.LocalDate类

public class LocalDateDemo {
    public static void main(String[] args) {
        //1.获取当前时间的日历对象(包含:年月日)
        LocalDate nowDate = LocalDate.now();
        System.out.println("今天的日期:" + nowDate);//2024-05-26
        System.out.println("----------------------------------");

        //2.获取指定的时间的日历对象
        LocalDate ldDate = LocalDate.of(2023, 1, 1);
        System.out.println("指定日期:" + ldDate);//2023-01-01
        System.out.println("----------------------------------");

        //3.get系列方法获取日历中的每一个属性值
        int year = ldDate.getYear();
        System.out.println("year:" + year);
        System.out.println("----------------------------------");

        //获取月
        //方式一
        Month m = ldDate.getMonth();
        System.out.println(m);//JANUARY
        System.out.println(m.getValue());
        System.out.println("----------------------------------");

        //方式二
        int month = ldDate.getMonthValue();
        System.out.println("month:" + month);
        System.out.println("----------------------------------");

        //获取日
        int day = ldDate.getDayOfMonth();
        System.out.println("day:" + day);
        System.out.println("----------------------------------");

        //获取一年的第几天
        int dayOfYear = ldDate.getDayOfYear();
        System.out.println("dayOfYear:" + dayOfYear);
        System.out.println("----------------------------------");

        //获取星期
        DayOfWeek dayOfWeek = ldDate.getDayOfWeek();
        System.out.println(dayOfWeek);//SUNDAY
        System.out.println(dayOfWeek.getValue());
        System.out.println("----------------------------------");

        //4.is开头的方法表示判断
        System.out.println(ldDate.isBefore(ldDate));
        System.out.println(ldDate.isAfter(ldDate));
        System.out.println("----------------------------------");

        //5.with开头的方法表示修改,只能修改年月日
        LocalDate withLocalDate = ldDate.withYear(2000);
        System.out.println(withLocalDate);
        System.out.println("----------------------------------");

        //6.minus开头的方法表示减少,只能减少年月日
        LocalDate minusYears = ldDate.minusYears(1);
        System.out.println(minusYears);
        System.out.println("----------------------------------");

        //7.plus开头的方法表示增加,只能增加年月日
        LocalDate plusYears = ldDate.plusYears(10);
        System.out.println(plusYears);
        System.out.println("----------------------------------");
    }
}

 细节:

① 通过getMonth 和 getDayOfWeek 方法,获取到的都是对象,不是值。

② LocalDate类的with、minus和plus方法,都只能修改年月日。

③ 修改后不会改变原对象(调用者)的值,而是创建了一个新的对象。

2.LocalTime类

public class LocalTimeDemo {
    public static void main(String[] args) {
        // 获取本地时间的日历对象。(包含 时分秒)
        LocalTime nowTime = LocalTime.now();
        System.out.println("今天的时间:" + nowTime);

        int hour = nowTime.getHour();//时
        System.out.println("hour: " + hour);

        int minute = nowTime.getMinute();//分
        System.out.println("minute: " + minute);

        int second = nowTime.getSecond();//秒
        System.out.println("second:" + second);

        int nano = nowTime.getNano();//纳秒
        System.out.println("nano:" + nano);
        System.out.println("------------------------------------");
        System.out.println(LocalTime.of(8, 20));//时分
        System.out.println(LocalTime.of(8, 20, 30));//时分秒
        System.out.println(LocalTime.of(8, 20, 30, 150));//时分秒纳秒
        LocalTime mTime = LocalTime.of(8, 20, 30, 150);

        //is系列的方法
        System.out.println(nowTime.isBefore(mTime));
        System.out.println(nowTime.isAfter(mTime));

        //with系列的方法,只能修改时、分、秒
        System.out.println(nowTime.withHour(10));

        //minus系列的方法,只能减少时、分、秒
        System.out.println(nowTime.minusHours(10));

        //plus系列的方法,只能增加时、分、秒
        System.out.println(nowTime.plusHours(10));
    }
}

细节:

 LocalTime类的get方法只能获取时分秒(纳秒)。

② LocalTime类的with、minus和plus方法,都只能修改时分秒(纳秒)。

③ 修改后不会改变原对象(调用者)的值,而是创建了一个新的对象。

3.LocalDateTime类

public class LocalDateTimeDemo {
    public static void main(String[] args) {
        // 当前时间的的日历对象(包含年月日时分秒)
        LocalDateTime nowDateTime = LocalDateTime.now();

        System.out.println("今天是:" + nowDateTime);//今天是:
        System.out.println(nowDateTime.getYear());//年
        System.out.println(nowDateTime.getMonthValue());//月
        System.out.println(nowDateTime.getDayOfMonth());//日
        System.out.println(nowDateTime.getHour());//时
        System.out.println(nowDateTime.getMinute());//分
        System.out.println(nowDateTime.getSecond());//秒
        System.out.println(nowDateTime.getNano());//纳秒
        // 日:当年的第几天
        System.out.println("dayofYear:" + nowDateTime.getDayOfYear());
        //星期
        System.out.println(nowDateTime.getDayOfWeek());
        System.out.println(nowDateTime.getDayOfWeek().getValue());
        //月份
        System.out.println(nowDateTime.getMonth());
        System.out.println(nowDateTime.getMonth().getValue());

        //转换成LocalDate对象
        LocalDate ld = nowDateTime.toLocalDate();
        System.out.println(ld);

        //转换成LocalTime对象
        LocalTime lt = nowDateTime.toLocalTime();
        System.out.println(lt.getHour());
        System.out.println(lt.getMinute());
        System.out.println(lt.getSecond());
    }
}

细节:

① LocalDateTime 类的信息最全,包含年月日时分秒

② 修改后不会改变原对象(调用者)的值,而是创建了一个新的对象。

③ LocalDateTime 对象还可以转换成 LocalDate 对象和 LocalTime 对象。

六、工具类

1.Period类

public class PeriodDemo {
    public static void main(String[] args) {
        //当前本地  年月日
        LocalDate today=LocalDate.now();
        System.out.println(today);//2024-05-28

        //出生日期  年月日
        LocalDate birth=LocalDate.of(2001,1,1);

        Period period= Period.between(birth,today);
        System.out.println("相差的时间间隔对象"+ period);//P23Y4M27D

        //相差的年月日
        System.out.println(period.getYears());//23
        System.out.println(period.getMonths());//4
        System.out.println(period.getDays());//27

        //相差的总月份
        System.out.println(period.toTotalMonths());//280

    }
}

细节:

① 在调用between方法计算时间间隔时,是第二个参数减去第一个参数 。

② Period 类侧重于年月日的计算,可以通过getxxx方法,获取 Period 时间间隔对象的年月日。

③ 可以通过 toxxx 方法转换成总共相差的年/月/日。 

2.Duration类

public class DurationDemo {
    public static void main(String[] args) {
        //当前本地时间对象
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);//2024-05-28T15:21:29.975429400

        //出生的日期时间对象
        LocalDateTime birth = LocalDateTime.of(2000, 1, 1, 00, 00, 00);

        Duration duration = Duration.between(birth, today);
        System.out.println("相差的时间间隔对象" + duration);//PT213951H21M29.9754294S

        //获取时间间隔对象的纳秒
        System.out.println(duration.getNano());

        //相差的总天数/小时数/分钟数/秒数/毫秒数/纳秒数
        System.out.println(duration.toDays());//8914
        System.out.println(duration.toHours());
        System.out.println(duration.toMinutes());
        System.out.println(duration.toSeconds());
        System.out.println(duration.toMillis());
        System.out.println(duration.toNanos());

    }
}

细节:

① 在调用between方法计算时间间隔时,是第二个参数减去第一个参数 。

② Duration类侧重于秒和纳秒的计算,相对来说比较精确一点,可以通过getNano方法,获取 Period 时间间隔对象的纳秒值。

③ 可以通过 toxxx 方法转换成总共相差的 天数/小时数/分钟数/秒数/毫秒数/纳秒数。

3.ChronoUnit类

public class ChronoUnitDemo {
    public static void main(String[] args) {
        // 当前本地时间对象
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);//2024-05-28T15:42:34.595451500
        // 出生的日期时间对象
        LocalDateTime birthDate = LocalDateTime.of(2000, 1, 1,
                0, 0, 0);

        //ChronoUnit.XXX.between()  可以计算两个时间相差的XXX
        System.out.println("相差的年数:" + ChronoUnit.YEARS.between(birthDate, today));
        System.out.println("相差的月数:" + ChronoUnit.MONTHS.between(birthDate, today));
        System.out.println("相差的周数:" + ChronoUnit.WEEKS.between(birthDate, today));
        System.out.println("相差的天数:" + ChronoUnit.DAYS.between(birthDate, today));
        System.out.println("相差的时数:" + ChronoUnit.HOURS.between(birthDate, today));
        System.out.println("相差的分数:" + ChronoUnit.MINUTES.between(birthDate, today));
        System.out.println("相差的秒数:" + ChronoUnit.SECONDS.between(birthDate, today));
        System.out.println("相差的毫秒数:" + ChronoUnit.MILLIS.between(birthDate, today));
        System.out.println("相差的微秒数:" + ChronoUnit.MICROS.between(birthDate, today));
        System.out.println("相差的纳秒数:" + ChronoUnit.NANOS.between(birthDate, today));
        System.out.println("相差的半天数:" + ChronoUnit.HALF_DAYS.between(birthDate, today));
        System.out.println("相差的十年数:" + ChronoUnit.DECADES.between(birthDate, today));
        System.out.println("相差的世纪(百年)数:" + ChronoUnit.CENTURIES.between(birthDate, today));
        System.out.println("相差的千年数:" + ChronoUnit.MILLENNIA.between(birthDate, today));
        System.out.println("相差的纪元数:" + ChronoUnit.ERAS.between(birthDate, today));
    }
}

细节:

最为常用,因为其能计算的单位非常多,是最全面的。

② 通过 ChronoUnit.XXX.between() 可以计算两个时间相差的XXX

 

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

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

相关文章

Linux 进程相关概念

用以下指令查找正在运行的进程&#xff0c;并使用 grep 过滤出包含 "int" 的行。 "ps -aux" 显示当前系统上所有用户的进程列表&#xff0c;而 grep 命令则筛选出包含 "int" 的行。 ps -aux|grep int p代表process进程 1.什么是程序&#xff…

JavaScript(ES6)入门

ES6 1、介绍 ECMAScript 6&#xff08;简称ES6&#xff09;是于2015年6月正式发布的JavaScript 语言的标准&#xff0c;正式名为ECMAScript 2015&#xff08;ES2015&#xff09;。它的目标是使得JavaScript语言可以用来编写复杂的大型应用程序&#xff0c;成为企业级开发语言。…

unity回到低版本报错解决

用高版本2022打开过后的再回到2020就报了一个错。 报错如下&#xff1a; Library\PackageCache\com.unity.ai.navigation1.1.5\Runtime\NavMeshSurface.cs 看了一下是Library&#xff0c;然后我删除了整个Library文件夹&#xff0c;重启启动生成Library&#xff0c;然后还是…

【全开源】在线题库微信小程序系统源码(ThinkPHP+FastAdmin+UniApp)

打造个性化学习平台 一、引言&#xff1a;在线学习的未来趋势 在数字化时代&#xff0c;线上学习已逐渐成为主流。随着移动互联网的普及&#xff0c;小程序以其轻便、快捷、无需安装的特点&#xff0c;成为用户日常学习的新选择。为了满足广大用户对于在线学习的需求&#xf…

分治法(棋盘覆盖问题)

目录 前言 一、棋盘覆盖 二、图示解析 三、代码实现 四、具体分析 总结 前言 有一个 x &#xff08;k>0&#xff09;的棋盘&#xff0c;恰好有一个方格与其他方格不同&#xff0c;称之为特殊方格。现在要用L形骨牌覆盖除了特殊方格以外的其他全部方格&#xff0c;骨牌可以…

2.8万字总结:金融核心系统数据库升级路径与场景实践

OceanBase CEO 杨冰 谈及数字化转型&#xff0c;如果说过去还只是头部金融机构带动效应下的“选择题”。那么现在&#xff0c;我相信数字化转型已经成为不论大、中、小型金融机构的“必答题”。 本文为OceanBase最新发布的《万字总结&#xff1a;金融核心系统数据库升级路径…

【ARM+Codesys案例】基于全志T3+Codesys的快递物流单件分离器控制系统

物流涉及国计民生&#xff0c;是在社会发展中不可或缺的一环。随着社会的改革开放&#xff0c;工业发展迅猛&#xff0c;此时也伴随着物流业的快速发展。电商、快递等行业业务量爆发以及人工成本的不断上涨&#xff0c;自动化输送分拣设备市场呈现井喷式发展。物流行业从传统方…

Linux——Docker容器虚拟化平台

安装docker 安装 Docker | Docker 从入门到实践https://vuepress.mirror.docker-practice.com/install/ 不需要设置防火墙 docker命令说明 docker images #查看所有本地主机的镜像 docker search 镜像名 #搜索镜像 docker pull 镜像名 [标签] #下载镜像&…

navicat连接过的库忘记密码

1、点击文件->导出连接 2、勾选想要知道密码的库 3、打开导出的文件搜索Password 4、复制Password解密 把下面的php代码复制到在线运行php的网站&#xff0c;替换最下面的decrypt(‘B7246A6E64D4F50A563FA20427A47991’)括号里的内容&#xff0c;然后执行php代码&#xff0…

Thinkphp5响应式进销存仓库管理系统

随着企业规模的不断扩大和市场竞争的日益激烈&#xff0c;进销存管理在企业的运营中扮演着越来越重要的角色。为了提高企业的运营效率&#xff0c;降低库存成本&#xff0c;提升客户满意度&#xff0c;越来越多的企业开始引入进销存仓库管理系统。 进销存仓库管理系统是一种集…

洛谷 CF1209D Cow and Snacks

题目来源于&#xff1a;洛谷 题目本质&#xff1a;并查集 解题思路&#xff1a; 我们以每种化为一个点&#xff0c;以每个客人喜欢的两朵花给两朵花连一条无向边。则会出现一定数目的连通块&#xff0c;连通块总个数为 ans。 对每个连通块进行分析&#xff1a;第一个客人买走…

大模型部署推理应用技术浅析

大模型完成预训练后不是就万事大吉了&#xff0c;离推理应用还有很大距离&#xff0c;需要经过微调、部署等一系列工程化工作。尤其是在2B的行业大模型应用中&#xff0c;为解决大模型的幻觉、时效性和推理成本问题&#xff0c;需要建立单一模型之上的体系。模型部署中的技术大…

基于物联网技术的智能家居实训教学解决方案

引言 随着信息技术的飞速发展&#xff0c;&#xff0c;物联网&#xff08;IoT&#xff09;已深入至我们生活的每一个角落&#xff0c;从智能家居、智能健康、智能交通到智慧城市&#xff0c;无所不在。物联网技术已成为推动社会进步和产业升级的重要力量。智能家居作为物联网技…

【最新更新】上市公司-全要素生产率(1999-2023年)(数据+5种方法测算)

上市公司的全要素生产率是指在一定时期内&#xff0c;上市公司通过使用各种生产要素(包括资本、劳动力、技术等)所创造的价值。它是衡量上市公司经营绩效的重要指标之一&#xff0c;可以反映出公司的生产效率和创新能力。全要素生产率的计算方法有很多种&#xff0c;其中最常见…

【堡垒机小知识】堡垒机和接口机的重要区别分析

在企业IT架构管理中&#xff0c;接口机和堡垒机各自扮演着不可或缺的角色。但不少IT小伙伴对于两者不是很了解&#xff0c;不知道两者之间有什么区别&#xff0c;今天我们就来一起分析一下。 堡垒机和接口机的重要区别分析 1、功能区别 接口机主要用于数据库层面的数据交换和…

大学运动康复试题及答案,分享几个实用搜题和学习工具 #其他#职场发展

大学生除了学习专业知识外&#xff0c;还应该关注和学习一些软技能&#xff0c;如沟通能力、团队合作和领导力等&#xff0c;以提升自己的综合素质。 1.滴墨书摘 这款软件相当于一个在线“摘抄本”&#xff0c;我们可以利用它来记录一些阅读时遇到的好句子或者是段落&#xf…

【Linux】使用 s3fs 挂载 MinIO 桶

s3fs&#xff08;S3 File System&#xff09;是一个基于FUSE&#xff08;Filesystem in Userspace&#xff09;的用户空间文件系统&#xff0c;可以将Amazon S3存储桶挂载到本地文件系统。通过s3fs&#xff0c;我们可以像操作本地文件一样&#xff0c;对S3存储桶中的数据进行读…

关于如何通过APlayer+MetingJS为自己的wordpress博客网页添加网易音乐播放器(无需插件)

本文转自博主的个人博客&#xff1a;https://blog.zhumengmeng.work,欢迎大家前往查看。 原文链接&#xff1a;点我访问 序言&#xff1a;最近在网上冲浪&#xff0c;发现大家的博客大部分都有一个音乐播放器能够播放音乐&#xff0c;随机我也开始寻找解决方法。可是找来找去我…

磁盘问题——外部、动态,无法读取

今天&#xff0c;小编又遇到事了&#xff0c;给同事换个电脑&#xff0c;要把他原来的硬盘拆过去&#xff0c;一开始电脑都准备好了&#xff0c;就差拆他的硬盘了&#xff0c;结果装过去&#xff0c;问题来啦&#xff01;如下图所示&#xff1a; 这下可咋搞呢&#xff01;我先用…

[STM32+HAL]LD-1501MG舵机二次开发指南

一、准备材料 核心板&#xff1a;STM32F407ZGT6 舵机&#xff1a;LD-1501MG数字舵机 控制器&#xff1a;24路PWM舵机控制器 二、HAL库配置 开启串口与控制器通信 三、Keil填写代码 1、Servo.c #include "Servo.h" #include "usart.h"uint8_t Message…