title: LocalDate VS Date
date: 2021-07-18 14:39:04
tags: Java
Description: This article is talking about the difference between LocalDate and Date in Java. Because most of the time, I can not distinguish them clearly, so write this article to record it.
-
LocalDate: only shows the date not include the specific time
-
Date: can records specific time
-
Example:
System.out.println("this is LocalDate: "+LocalDate.now());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
System.out.println("this is date: "+dateFormat.format(date));