从前面的系列博客中可以看出Jdk8中java.time包中的新的日期时间API类设计的很好,但Date由于使用仍非常广泛,这就涉及到Date转LocalDateTime,LocalDateTime转Date。下面是时间类互相转换大全,包含Instant、LocalDate、LocalDateTime、LocalTime、ZonedDateTime和Date的相互转换,时间转换大全,下面是一个工具类,仅供参考:

具体包含:

LocalDateTime转Date,LocalDate转Date,LocalTime转Date,Instant转Date,epochMilli毫秒转Date,ZonedDateTime转Date,Date转LocalDateTime,LocalDate转LocalDateTime,LocalTime转LocalDateTime,Instant转LocalDateTime,epochMilli毫秒转LocalDateTime,temporal转LocalDateTime,ZonedDateTime转LocalDateTime,Date转LocalDate,LocalDateTime转LocalDate,Instant转LocalDate,temporal转LocalDate,ZonedDateTime转LocalDate,Date转LocalTime,LocalDateTime转LocalTime,Instant转LocalTime,temporal转LocalTime,ZonedDateTime转LocalTime,Date转Instant,LocalDateTime转Instant,LocalDate转Instant,LocalTime转Instant,epochMilli毫秒转Instant,temporal转Instant,ZonedDateTime转Instant,Date转毫秒值,LocalDateTime转毫秒值,LocalDate转毫秒值,Instant转毫秒值,ZonedDateTime转毫秒值,Date转ZonedDateTime,LocalDateTime转ZonedDateTime,LocalDate转ZonedDateTime,LocalTime转ZonedDateTime,Instant转ZonedDateTime,epochMilli毫秒转ZonedDateTime,temporal转ZonedDateTime.

package com.xkzhangsan.time.converter;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
import java.util.Date;
import java.util.Objects; /**
* 日期转换
* 包含Date、LocalDate、LocalDateTime、LocalTime、Instant和ZonedDateTime的互相转换
*
* 注意,ZonedDateTime相关的转换,尤其是其他时间转ZonedDateTime,要注意时间和对应时区一致。
* @ClassName: DateTimeConverterUtil
* @Description: DateTime Converter
* @author xkzhangsan
* @date 2019年12月1日
*
*/
public class DateTimeConverterUtil { private DateTimeConverterUtil(){
} /**
* LocalDateTime转Date
* @param localDateTime
* @return
*/
public static Date toDate(LocalDateTime localDateTime) {
Objects.requireNonNull(localDateTime, "localDateTime");
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
} /**
* LocalDate转Date
* @param localDate
* @return
*/
public static Date toDate(LocalDate localDate) {
Objects.requireNonNull(localDate, "localDate");
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
} /**
* LocalTime转Date
* 以当天的日期+LocalTime组成新的LocalDateTime转换为Date
* @param localTime
* @return
*/
public static Date toDate(LocalTime localTime) {
Objects.requireNonNull(localTime, "localTime");
return Date.from(LocalDate.now().atTime(localTime).atZone(ZoneId.systemDefault()).toInstant());
} /**
* Instant转Date
* @param instant
* @return
*/
public static Date toDate(Instant instant) {
return Date.from(instant);
} /**
* epochMilli毫秒转Date
* @param epochMilli
* @return
*/
public static Date toDate(long epochMilli){
Objects.requireNonNull(epochMilli, "epochMilli");
return new Date(epochMilli);
} /**
* ZonedDateTime转Date
* 注意时间对应的时区和默认时区差异
* @param zonedDateTime
* @return
*/
public static Date toDate(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return Date.from(zonedDateTime.toInstant());
} /**
* Date转LocalDateTime
* @param date
* @return
*/
public static LocalDateTime toLocalDateTime(Date date) {
Objects.requireNonNull(date, "date");
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
} /**
* LocalDate转LocalDateTime
* @param localDate
* @return
*/
public static LocalDateTime toLocalDateTime(LocalDate localDate) {
Objects.requireNonNull(localDate, "localDate");
return localDate.atStartOfDay();
} /**
* LocalTime转LocalDateTime
* 以当天的日期+LocalTime组成新的LocalDateTime
* @param localTime
* @return
*/
public static LocalDateTime toLocalDateTime(LocalTime localTime) {
Objects.requireNonNull(localTime, "localTime");
return LocalDate.now().atTime(localTime);
} /**
* Instant转LocalDateTime
* @param instant
* @return
*/
public static LocalDateTime toLocalDateTime(Instant instant) {
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
} /**
* epochMilli毫秒转LocalDateTime
* @param epochMilli
* @return
*/
public static LocalDateTime toLocalDateTime(long epochMilli) {
Objects.requireNonNull(epochMilli, "epochMilli");
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.systemDefault());
} /**
* temporal转LocalDateTime
* @param temporal
* @return
*/
public static LocalDateTime toLocalDateTime(TemporalAccessor temporal) {
return LocalDateTime.from(temporal);
} /**
* ZonedDateTime转LocalDateTime
* 注意时间对应的时区和默认时区差异
* @param zonedDateTime
* @return
*/
public static LocalDateTime toLocalDateTime(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return zonedDateTime.toLocalDateTime();
} /**
* Date转LocalDate
* @param date
* @return
*/
public static LocalDate toLocalDate(Date date) {
return toLocalDateTime(date).toLocalDate();
} /**
* LocalDateTime转LocalDate
* @param localDateTime
* @return
*/
public static LocalDate toLocalDate(LocalDateTime localDateTime) {
Objects.requireNonNull(localDateTime, "localDateTime");
return localDateTime.toLocalDate();
} /**
* Instant转LocalDate
* @param instant
* @return
*/
public static LocalDate toLocalDate(Instant instant) {
return toLocalDateTime(instant).toLocalDate();
} /**
* temporal转LocalDate
* @param temporal
* @return
*/
public static LocalDate toLocalDate(TemporalAccessor temporal) {
return LocalDate.from(temporal);
} /**
* ZonedDateTime转LocalDate
* 注意时间对应的时区和默认时区差异
* @param zonedDateTime
* @return
*/
public static LocalDate toLocalDate(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return zonedDateTime.toLocalDate();
} /**
* Date转LocalTime
* @param date
* @return
*/
public static LocalTime toLocalTime(Date date) {
return toLocalDateTime(date).toLocalTime();
} /**
* LocalDateTime转LocalTime
* @param localDateTime
* @return
*/
public static LocalTime toLocalTime(LocalDateTime localDateTime) {
Objects.requireNonNull(localDateTime, "localDateTime");
return localDateTime.toLocalTime();
} /**
* Instant转LocalTime
* @param instant
* @return
*/
public static LocalTime toLocalTime(Instant instant) {
return toLocalDateTime(instant).toLocalTime();
} /**
* temporal转LocalTime
* @param temporal
* @return
*/
public static LocalTime toLocalTime(TemporalAccessor temporal) {
return LocalTime.from(temporal);
} /**
* ZonedDateTime转LocalTime
* 注意时间对应的时区和默认时区差异
* @param zonedDateTime
* @return
*/
public static LocalTime toLocalTime(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return zonedDateTime.toLocalTime();
} /**
* Date转Instant
* @param date
* @return
*/
public static Instant toInstant(Date date) {
Objects.requireNonNull(date, "date");
return date.toInstant();
} /**
* LocalDateTime转Instant
* @param localDateTime
* @return
*/
public static Instant toInstant(LocalDateTime localDateTime) {
Objects.requireNonNull(localDateTime, "localDateTime");
return localDateTime.atZone(ZoneId.systemDefault()).toInstant();
} /**
* LocalDate转Instant
* @param localDate
* @return
*/
public static Instant toInstant(LocalDate localDate) {
return toLocalDateTime(localDate).atZone(ZoneId.systemDefault()).toInstant();
} /**
* LocalTime转Instant
* 以当天的日期+LocalTime组成新的LocalDateTime转换为Instant
* @param localTime
* @return
*/
public static Instant toInstant(LocalTime localTime) {
return toLocalDateTime(localTime).atZone(ZoneId.systemDefault()).toInstant();
} /**
* epochMilli毫秒转Instant
* @param epochMilli
* @return
*/
public static Instant toInstant(long epochMilli) {
Objects.requireNonNull(epochMilli, "epochMilli");
return Instant.ofEpochMilli(epochMilli);
} /**
* temporal转Instant
* @param temporal
* @return
*/
public static Instant toInstant(TemporalAccessor temporal) {
return Instant.from(temporal);
} /**
* ZonedDateTime转Instant
* 注意时间对应的时区和默认时区差异
* @param zonedDateTime
* @return
*/
public static Instant toInstant(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return zonedDateTime.toInstant();
} /**
* Date转毫秒值
* 从1970-01-01T00:00:00Z开始的毫秒值
* @param date
* @return
*/
public static long toEpochMilli(Date date){
Objects.requireNonNull(date, "date");
return date.getTime();
} /**
* LocalDateTime转毫秒值
* 从1970-01-01T00:00:00Z开始的毫秒值
* @param localDateTime
* @return
*/
public static long toEpochMilli(LocalDateTime localDateTime){
return toInstant(localDateTime).toEpochMilli();
} /**
* LocalDate转毫秒值
* 从1970-01-01T00:00:00Z开始的毫秒值
* @param localDate
* @return
*/
public static long toEpochMilli(LocalDate localDate){
return toInstant(localDate).toEpochMilli();
} /**
* Instant转毫秒值
* 从1970-01-01T00:00:00Z开始的毫秒值
* @param instant
* @return
*/
public static long toEpochMilli(Instant instant){
Objects.requireNonNull(instant, "instant");
return instant.toEpochMilli();
} /**
* ZonedDateTime转毫秒值,注意时间对应的时区和默认时区差异
* 从1970-01-01T00:00:00Z开始的毫秒值
* @param zonedDateTime
* @return
*/
public static long toEpochMilli(ZonedDateTime zonedDateTime) {
Objects.requireNonNull(zonedDateTime, "zonedDateTime");
return zonedDateTime.toInstant().toEpochMilli();
} /**
* Date转ZonedDateTime,时区为系统默认时区
* @param date
* @return
*/
public static ZonedDateTime toZonedDateTime(Date date) {
Objects.requireNonNull(date, "date");
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()
.atZone(ZoneId.systemDefault());
} /**
* LocalDateTime转ZonedDateTime,时区为系统默认时区
* @param localDateTime
* @return
*/
public static ZonedDateTime toZonedDateTime(LocalDateTime localDateTime) {
Objects.requireNonNull(localDateTime, "localDateTime");
return localDateTime.atZone(ZoneId.systemDefault());
}

/**
* LocalDateTime转ZonedDateTime,时区为zoneId对应时区
* 注意,需要保证localDateTime和zoneId是对应的,不然会出现错误
*
* @param localDateTime
* @param zoneId
* @return
*/
public static ZonedDateTime toZonedDateTime(LocalDateTime localDateTime, String zoneId) {
  Objects.requireNonNull(localDateTime, "localDateTime");
  Objects.requireNonNull(zoneId, "zoneId");
  return localDateTime.atZone(ZoneId.of(zoneId));
}

/**
* LocalDate转ZonedDateTime,时区为系统默认时区
* @param localDate
* @return such as 2020-02-19T00:00+08:00[Asia/Shanghai]
*/
public static ZonedDateTime toZonedDateTime(LocalDate localDate) {
Objects.requireNonNull(localDate, "localDate");
return localDate.atStartOfDay().atZone(ZoneId.systemDefault());
} /**
* LocalTime转ZonedDateTime
* 以当天的日期+LocalTime组成新的ZonedDateTime,时区为系统默认时区
* @param localTime
* @return
*/
public static ZonedDateTime toZonedDateTime(LocalTime localTime) {
Objects.requireNonNull(localTime, "localTime");
return LocalDate.now().atTime(localTime).atZone(ZoneId.systemDefault());
} /**
* Instant转ZonedDateTime,时区为系统默认时区
* @param instant
* @return
*/
public static ZonedDateTime toZonedDateTime(Instant instant) {
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).atZone(ZoneId.systemDefault());
} /**
* epochMilli毫秒转ZonedDateTime,时区为系统默认时区
* @param epochMilli
* @return
*/
public static ZonedDateTime toZonedDateTime(long epochMilli) {
Objects.requireNonNull(epochMilli, "epochMilli");
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.systemDefault())
.atZone(ZoneId.systemDefault());
} /**
* temporal转ZonedDateTime,时区为系统默认时区
* @param temporal
* @return
*/
public static ZonedDateTime toZonedDateTime(TemporalAccessor temporal) {
return LocalDateTime.from(temporal).atZone(ZoneId.systemDefault());
} }

测试代码

package com.xkzhangsan.time.test;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.util.Date; import org.junit.Test; import com.xkzhangsan.time.converter.DateTimeConverterUtil; public class ConverterTest { @Test
public void dateConverterTest(){
System.out.println("===================dateConverterTest=====================");
Date date = new Date();
System.out.println(DateTimeConverterUtil.toLocalDateTime(date));
System.out.println(DateTimeConverterUtil.toLocalDate(date));
System.out.println(DateTimeConverterUtil.toLocalTime(date));
System.out.println(DateTimeConverterUtil.toInstant(date));
} @Test
public void localDateTimeConverterTest(){
System.out.println("===================localDateTimeConverterTest=====================");
LocalDateTime ldt = LocalDateTime.now();
System.out.println(ldt);
System.out.println(DateTimeConverterUtil.toDate(ldt));
System.out.println(DateTimeConverterUtil.toLocalDate(ldt));
System.out.println(DateTimeConverterUtil.toLocalTime(ldt));
System.out.println(DateTimeConverterUtil.toInstant(ldt));
System.out.println(DateTimeConverterUtil.toZonedDateTime(ldt));
} @Test
public void localDateConverterTest(){
System.out.println("===================localDateConverterTest=====================");
LocalDate ld = LocalDate.now();
System.out.println(ld);
System.out.println(DateTimeConverterUtil.toDate(ld));
System.out.println(DateTimeConverterUtil.toLocalDateTime(ld));
System.out.println(DateTimeConverterUtil.toInstant(ld));
} @Test
public void localTimeConverterTest(){
System.out.println("===================localTimeConverterTest=====================");
LocalTime lt = LocalTime.now();
System.out.println(lt);
System.out.println(DateTimeConverterUtil.toDate(lt));
System.out.println(DateTimeConverterUtil.toLocalDateTime(lt));
System.out.println(DateTimeConverterUtil.toLocalTime(lt));
System.out.println(DateTimeConverterUtil.toInstant(lt));
} @Test
public void instantConverterTest(){
System.out.println("===================instantConverterTest=====================");
Instant instant = Instant.now();
System.out.println(instant);
System.out.println(DateTimeConverterUtil.toDate(instant));
System.out.println(DateTimeConverterUtil.toLocalDateTime(instant));
System.out.println(DateTimeConverterUtil.toLocalDate(instant));
} @Test
public void zonedDateTimeConverterTest(){
System.out.println("===================zonedDateTimeConverterTest=====================");
System.out.println("===================ToOther=====================");
ZonedDateTime zonedDateTime = ZonedDateTime.now();
System.out.println(zonedDateTime);
System.out.println(DateTimeConverterUtil.toDate(zonedDateTime));
System.out.println(DateTimeConverterUtil.toLocalDateTime(zonedDateTime));
System.out.println(DateTimeConverterUtil.toLocalDate(zonedDateTime));
System.out.println(DateTimeConverterUtil.toLocalTime(zonedDateTime));
System.out.println(DateTimeConverterUtil.toInstant(zonedDateTime));
System.out.println("===================toZonedDateTime=====================");
System.out.println(zonedDateTime);
System.out.println(DateTimeConverterUtil.toZonedDateTime(new Date()));
System.out.println(DateTimeConverterUtil.toZonedDateTime(LocalDateTime.now()));
System.out.println(DateTimeConverterUtil.toZonedDateTime(LocalDate.now()));
System.out.println(DateTimeConverterUtil.toZonedDateTime(LocalTime.now()));
System.out.println(DateTimeConverterUtil.toZonedDateTime(Instant.now()));
}
}

输出:

===================dateConverterTest=====================
2020-02-19T16:10:04.366
2020-02-19
16:10:04.366
2020-02-19T08:10:04.366Z
===================localTimeConverterTest=====================
16:10:04.458
Wed Feb 19 16:10:04 CST 2020
2020-02-19T16:10:04.458
16:10:04.458
2020-02-19T08:10:04.458Z
===================localDateConverterTest=====================
2020-02-19
Wed Feb 19 00:00:00 CST 2020
2020-02-19T00:00
2020-02-18T16:00:00Z
===================zonedDateTimeConverterTest=====================
===================ToOther=====================
2020-02-19T16:10:04.464+08:00[Asia/Shanghai]
Wed Feb 19 16:10:04 CST 2020
2020-02-19T16:10:04.464
2020-02-19
16:10:04.464
2020-02-19T08:10:04.464Z
===================toZonedDateTime=====================
2020-02-19T16:10:04.464+08:00[Asia/Shanghai]
2020-02-19T16:10:04.465+08:00[Asia/Shanghai]
2020-02-19T16:10:04.465+08:00[Asia/Shanghai]
2020-02-19T00:00+08:00[Asia/Shanghai]
2020-02-19T16:10:04.466+08:00[Asia/Shanghai]
2020-02-19T16:10:04.466+08:00[Asia/Shanghai]
===================localDateTimeConverterTest=====================
2020-02-19T16:10:04.466
Wed Feb 19 16:10:04 CST 2020
2020-02-19
16:10:04.466
2020-02-19T08:10:04.466Z
2020-02-19T16:10:04.466+08:00[Asia/Shanghai]
===================instantConverterTest=====================
2020-02-19T08:10:04.467Z
Wed Feb 19 16:10:04 CST 2020
2020-02-19T16:10:04.467
2020-02-19

源码地址:https://github.com/xkzhangsan/xk-time

Java日期时间API系列13-----Jdk8中java.time包中的新的日期时间API类,时间类转换,Date转LocalDateTime,LocalDateTime转Date等的更多相关文章

  1. 在swt中获取jar包中的文件 uri is not hierarchical

    uri is not hierarchical 学习了:http://blog.csdn.net/zdsdiablo/article/details/1519719 在swt中获取jar包中的文件: ...

  2. API接口自动化之3 同一个war包中多个接口做自动化测试

    同一个war包中多个接口做自动化测试 一个接口用一个测试类,每个测试用例如下,比如下面是4个测试用例,每个详细的测试用例中含有请求入参,返回体校验,以此来判断每条测试用例是否通过 一个war包中,若含 ...

  3. Andriod项目开发实战(1)——如何在Eclipse中的一个包下建新包

    最开始是想将各个类分门别类地存放在不同的包中,所以想在项目源码包中新建几个不同功能的包eg:utils.model.receiver等,最后的结果应该是下图左边这样的:   很明显建立项目后的架构是上 ...

  4. Mac 如何导出ipa文件中Assets.car包中的切图

    在之前 获取 AppStore 中 应用 的 IPA 包文件(Mac OS 13+)中获取到应用的 IPA 包,可以取出应用的部分图片(如 Logo),如果项目工程中把图片添加到 Assets.xca ...

  5. JDK中的Atomic包中的类及使用

    引言 Java从JDK1.5开始提供了java.util.concurrent.atomic包,方便程序员在多线程环境下,无锁的进行原子操作.原子变量的底层使用了处理器提供的原子指令,但是不同的CPU ...

  6. 【转】Eclipse中查看jar包中的源码

    (简单的方式:通过jd-gui来进行反编译,最简单!,参考我的另一篇博文, 地址:http://www.cnblogs.com/gmq-sh/p/4277991.html) Java Decompil ...

  7. Package.json中dependencies依赖包中^符号和~符号前缀的区别

    刚git了webpack的包发现package.json里面dependencies依赖包的版本号前面的符号有两种,一种是~,一种是^,如下图标记: 然后搜了下在stackoverflow上找到一个比 ...

  8. Java8系列 (六) 新的日期和时间API

    概述 在Java8之前, 我们一般都是使用 SimpleDateFormat 来解析和格式化日期时间, 但它是线程不安全的. @Test public void test() { SimpleDate ...

  9. Java8 新的日期和时间API(笔记)

    LocalDate LocalTime Instant duration以及Period 使用LocalDate和LocalTime //2017-03-20 LocalDate date = Loc ...

  10. Redis总结(五)缓存雪崩和缓存穿透等问题 Web API系列(三)统一异常处理 C#总结(一)AutoResetEvent的使用介绍(用AutoResetEvent实现同步) C#总结(二)事件Event 介绍总结 C#总结(三)DataGridView增加全选列 Web API系列(二)接口安全和参数校验 RabbitMQ学习系列(六): RabbitMQ 高可用集群

    Redis总结(五)缓存雪崩和缓存穿透等问题   前面讲过一些redis 缓存的使用和数据持久化.感兴趣的朋友可以看看之前的文章,http://www.cnblogs.com/zhangweizhon ...

随机推荐

  1. AntDesign(React)学习-1 创建环境

    目录: AntDesign(React)学习-15 组件定义.connect.interface AntDesign(React)学习-14 使用UMI提供的antd模板 AntDesign(Reac ...

  2. [Java IO]05_JSON操作

    目录 6.1 JSON 知识背景  6.1.1 JSON 简介  6.1.2 JSON 语法  6.1.3 JSON 的数据结构6.2 Java 中操作 JSON 数据  6.2.1 Jar包下载   ...

  3. 记录 shell学习过程(4)for 循环

    1. for in ` #seq 生成从1到10 如果生成从10到1则写作 seq 10 -1 1 do echo $i done for in 也可以循环出字符串 for i in where is ...

  4. Windows10 远程桌面连接失败,报CredSSP加密oracle修正错误解决办法

    最近Windows10 升级后,发现不能远程连接. 不能访问的都报下面这个错了: 原因:按照提示的微软地址,看了下大致就是服务器端没有更新,而我的win10已经更新了一个安全补丁,如果双方都没有打补丁 ...

  5. python 百万级别类实例实现节省内存

    # 案例: ''' 某网络游戏中,定义了玩家类Player(id,name,status) 每当有一个玩家,就会在服务器创建一个Player实例 当在线人数过多时,将产生大量实例(百万级别),消耗内存 ...

  6. java fastjson:Map与json以及JSONObject ,JSONObject与String互转

    import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson ...

  7. android toolbar 显示返回按钮并改变按钮颜色

    <android.support.design.widget.AppBarLayout android:id="@+id/about_appbar" android:layo ...

  8. while、for循环结构_python

    一.while循环的基础例子: 例子1:判断是否大于50 例子2:按需打印乘法口诀 例子3:无限循环 while True: print (“true”) 二.for循环 1.for循环的常见范围的用 ...

  9. java_jsp_导入第三方jar包

    问题:把第三方jar包放在tomcat common/lib目录下之后,在jsp页面中引用不到 解决方法:将jar包放在你的项目目录下的WEB-INF/lib/目录下 解决 希望对大家又所帮助 以上

  10. Excel 不同文件、sheet 关联引用(vlookup函数)

    有时候在excel办公中会遇到,两个sheet相同的一列数据,作为关联(就像数据库的表的外键),其中一个sheet想要获取另一个sheet的其他列数据,这样就用到了vlookup函数,下面演示一下: ...