<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.0.7</version> </dependency>
package com.example.demo.hutool; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.Week; import java.util.Calendar; import java.util.Date; /** * @program: demo->DateDemo * @description: * @author: cxy * @create: 2019-12-12 09:21 * * / Public class DateDemo { public static void main (String [] args) { // Get the type of the result to the current date 10:18:11 2019-12-12 the DateTime DATE = DateUtil.date (); // obtained the current date type results 10:18:11 2019-12-12 the DateTime date1 = DateUtil.date (System.currentTimeMillis ()); // Get the type of the result to the current date 10:18:11 2019-12-12 a date DATE2 = DateUtil.date (); // Analyzing date comparison Boolean = before DateUtil.date () before (date1);. // Get time type "yyyy-MM-dd" . DateUtil.date String S = () toString ( " YYYY-the MM-dd " ); // after the current time to the DateTime now = DateTime.Now (); Calendar Calendar = DateUtil.calendar (); // Get data milliseconds Long timeInMillis = calendar.getTimeInMillis (); // get the current seconds Long L = DateUtil.currentSeconds (); // Get the current day of the month int I = DateUtil.thisDayOfMonth (); // get the first few days of the week int I1 = DateUtil.thisDayOfWeek (); // get the date in English Week Week = DateUtil.thisDayOfWeekEnum (); // Gets hours int i2 = DateUtil.thisHour ( to true ); //Year to get the current time int i3 = DateUtil.thisYear (); // Get the current quarter time DateTime dateTime = DateUtil.beginOfQuarter (now); // get the current quarter, which belongs String s1 = DateUtil.yearAndQuarter (now) .substring ( 4 ); // get the current time time 10:39:08 String s2 = DateUtil.formatTime (now); // get the start time of the day DateTime dateTime1 = DateUtil.beginOfDay (now); // get the end of the day DateTime = datetime2 DateUtil.endOfDay (now); System.out.println(date); System.out.println(date1); System.out.println(date2); System.out.println(before); System.out.println(s); System.out.println(timeInMillis); System.out.println(l); System.out.println(i); System.out.println(i1); System.out.println(i2); System.out.println(i3); System.out.println(week); System.out.println(dateTime); System.out.println(s1); System.out.println(s2); System.out.println(dateTime1); System.out.println(dateTime2); } }
l