Java does time processing
A Calendar,
(1) Introduction to Calender
The Chinese translation of Calendar is Calendar. In fact, there have been many ways of keeping time throughout history. So in order to synchronize timing, it is necessary to specify a calendar option. The Gregorian Calendar is the most popular and popular Calendar. That is, we often use the term “year” when we talk about years. Calendar is an Abstract Class in Java, and GregorianCalendar is a concrete implementation of it. The instance obtained in calendar.getInstance () is a “GreogrianCalendar” object.
(2) Simple date use
Calendar cal = Calendar.getInstance();
System.out.println(cal.get(Calendar.DATE));//----------------------- what's the date today
System.out.println(cal.get(Calendar.DAY_OF_MONTH));//--------------- Today is the day of January
System.out.println(cal.get(Calendar.DAY_OF_WEEK));//---------------- counting from Sunday, if today is Tuesday, return 3
System.out.println( cal.get(Calendar.DAY_OF_YEAR));//---------------- Today is the day of the year
System.out.println( cal.get(Calendar.HOUR));//----------------------- is now 12 hours
System.out.println( cal.get(Calendar.HOUR_OF_DAY));//---------------- is now in 24-hour mode and is usually assigned with this attribute
System.out.println(cal.get(Calendar.MILLISECOND));//---------------- now milliseconds
System.out.println( cal.get(Calendar.MINUTE));//--------------------- is now a few minutes
System.out.println( cal.get(Calendar.SECOND));//--------------------- is now seconds
System.out.println(cal.get(Calendar.WEEK_OF_MONTH));//-------------- this is the week of the month
System.out.println(cal.get(Calendar.WEEK_OF_YEAR));//---------------- this is the week of the year
System.out.println(cal.get(Calendar.MONTH));//----------------------- the month is +1, so the assignment is -1
System.out.println(cal.get(Calendar.MONTH)-1); // Get the month of the previous month
Copy the code
(3) Conversion between Date and Date
Calendar calendar = Calendar.getInstance();
// Get the Date object from a Calendar object
Date date = calendar.getTime();
// Reflect the Date object into a Calendar object,
// Get an instance, then set the Date objectcalendar.setTime(date); The month starts at 0 instead of 1, so to set August, we use 7 instead of 18. calendar.set(Calendar.MONTH,7); To calculate2000-01-01Calendar. Set (calendar.2000.1.1)
calendar.get(calendar.DAY_OF_WEEK )
Copy the code
Of course, Calender is the earliest time processing, is jdK1.6 things are inevitably more outdated
DateUtils under Apache
(1) Import package
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
Copy the code
(2), nothing to say on the translation of the line
/** * The number of milliseconds in seconds */
public static final long MILLIS_PER_SECOND = 1000
/** * The number of milliseconds in minutes */
public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND
/** * The number of milliseconds in hours */
public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE
/** * The number of milliseconds in day */
public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR
/** * This type is half a month, so this can represent whether the date is half a month up or down. * /
public static final int SEMI_MONTH = 1001
/** * week range, starting from Sunday. * /
public static final int RANGE_WEEK_SUNDAY = 1
/** * week range, starting from Monday. * /
public static final int RANGE_WEEK_MONDAY = 2
/** * week range, starting from the day of concern. * /
public static final int RANGE_WEEK_RELATIVE = 3
/** * week range, centered on the day of concern. * /
public static final int RANGE_WEEK_CENTER = 4
/** * month range, starting from Sunday. * /
public static final int RANGE_MONTH_SUNDAY = 5
/** * month range, starting from Monday. * /
public static final int RANGE_MONTH_MONDAY = 6
/** * Instead of fetching real columns in standard programming, use static methods in the class directly, such as dateutils.parsedate (STR). * This constructor is intended to allow use in tools that require a Javabeen real column. * /
public DateUtils(a)
/** * check whether two dates and times are the same day. * * @param date1 First date, unchangeable, non-null * @param date2 second date, unchangeable, non-null */
public static boolean isSameDay(final Date date1, final Date date2)
/** * Determine if two calendar times are the same day. * * @param cal1 First calendar, unchangeable, non-null * @param cal2 Second calendar, unchangeable, non-null */
public static boolean isSameDay(final Calendar cal1, final Calendar cal2)
* @param date2 first date, unmodifiable, non-null * @param date2 second date, unmodifiable, non-null */
public static boolean isSameInstant(final Date date1, final Date date2)
** @param cal1 first calendar, unmodifiable, non-null * @param cal2 second calendar, unmodifiable, non-null */
public static boolean isSameInstant(final Calendar cal1, final Calendar cal2)
** @param cal1 first calendar, unmodifiable, non-null * @param cal2 Second calendar, unmodifiable, non-null */
public static boolean isSameLocalTime(final Calendar cal1, final Calendar cal2)
/** * Try parsing the string STR for time using the various date formats in parsePatterns. * * parsing uses the formats in parsePatterns one by one and throws a ParseException if none of them match. * * @param STR parsed time string, non-null * @param parsePatterns is used to parse the time format of STR. There are one or more, non-null */
public static Date parseDate(final String str, final String... parsePatterns) throws ParseException
/** * Try parsing the string STR for time using the various date formats in parsePatterns. * The given date formatter locale is used for parsing. * * parsing uses the formats in parsePatterns one by one and throws a ParseException if none of them match. * * @param STR parsed time string, non-null * @param locale uses the date format in locale, if null, The system's default locale * @param parsePatterns is used to resolve the time format of STR, which has one or more non-null */
public static Date parseDate(final String str, final Locale locale, final String... parsePatterns) throws ParseException
/** * Try parsing the string STR for time using the various date formats in parsePatterns. * * parsing uses the formats in parsePatterns one by one and throws a ParseException if none of them match. * The parser parses strictly disallowed dates, such as "February 942, 1996". * * @param STR parsed time string, non-null * @param parsePatterns is used to parse the time format of STR. There are one or more, non-null */
public static Date parseDateStrictly(final String str, final String... parsePatterns) throws ParseException
/** * Try parsing the string STR for time using the various date formats in parsePatterns. * The given date formatter locale is used for parsing. * * parsing uses the formats in parsePatterns one by one and throws a ParseException if none of them match. * The parser parses strictly disallowed dates, such as "February 942, 1996". * * @param STR parsed time string, non-null * @param locale uses the date format in locale, if null, The system's default locale * @param parsePatterns is used to resolve the time format of STR, which has one or more non-null */
public static Date parseDateStrictly(final String str, final Locale locale, final String... parsePatterns) throws ParseException
/** * add amount years to date. * * @param date Date of processing, non-null * @param amount Number of years to be added, possibly negative */
public static Date addYears(final Date date, final int amount)
/** * add amount month to date. * * @param date Date for processing, non-null * @param amount Number of months to be added, possibly negative */
public static Date addMonths(final Date date, final int amount)
/** * add amount week to date. * * @param date Date for processing, non-null * @param amount Number of weeks to be added, possibly negative */
public static Date addWeeks(final Date date, final int amount)
/** * add amount days to date. * * @param date Date for processing, non-null * @param amount Number of days to add, possibly negative */
public static Date addDays(final Date date, final int amount)
/** * add amount hour to date. * * @param date Date for processing, non-null * @param amount Number of hours to add, possibly negative */
public static Date addHours(final Date date, final int amount)
/** * add amount minutes to date. * * @param date Date of processing, non-null * @param amount Number of minutes to be added, possibly negative */
public static Date addMinutes(final Date date, final int amount)
/** * add amount seconds to date. * * @param date Date of processing, non-null * @param amount Number of seconds to be added, possibly negative */
public static Date addSeconds(final Date date, final int amount)
/** * add amount milliseconds to date. * * @param date Date for processing, non-null * @param amount Number of milliseconds to be added, possibly negative */
public static Date addMilliseconds(final Date date, final int amount)
/** * sets a New Year for the date data. * * @param date The processing date, non-null * @param amount The year to be set */
public static Date setYears(final Date date, final int amount)
/** * set a new month for the date data. * * @param date The processing date, non-null * @param amount The month to be set */
public static Date setMonths(final Date date, final int amount)
/** * set a new day for the date data. * * @param date The processing date, non-null * @param amount The day to set */
public static Date setDays(final Date date, final int amount)
/** * sets a new hour for the date data. * * @param date The processing date, non-null * @param amount The hour to be set */
public static Date setHours(final Date date, final int amount)
/** * set a new minute for the date data. * * @param date Date for processing, non-null * @param amount Number of minutes to set */
public static Date setMinutes(final Date date, final int amount)
/** * sets a new second for the date data. * * @param date The processing date, non-null * @param amount The second to be set */
public static Date setSeconds(final Date date, final int amount)
/** * sets a new millisecond for the date data. * * @param date The processing date, non-null * @param amount The milliseconds to be set */
public static Date setMilliseconds(final Date date, final int amount)
/** * puts a date in a calendar. * /
public static Calendar toCalendar(final Date date)
/** * Round the calendar date according to the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it returns 1 April 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date round(final Date date, final int field)
/** * Round the calendar date according to the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it returns 1 April 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Calendar round(final Calendar date, final int field)
/** * Round the calendar date according to the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it returns 1 April 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date round(final Object date, final int field)
/** * Cut the date according to the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 13:00:00.000; * If field is MONTH, it will return 1 Mar 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date truncate(final Date date, final int field)
/** * Intercepts calendar dates based on the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 13:00:00.000; * If field is MONTH, it will return 1 Mar 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Calendar truncate(final Calendar date, final int field)
/** * Cut the date according to the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 13:00:00.000; * If field is MONTH, it will return 1 Mar 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date truncate(final Object date, final int field)
/** * Round up the date date based on the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it will return 1 Apr 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date ceiling(final Date date, final int field)
/** * Round up the date date based on the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it will return 1 Apr 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Calendar ceiling(final Calendar date, final int field)
/** * Round up the date date based on the threshold field. * * For example, if your time is 28 Mar 2002 13:45:01.231, * if field is HOUR, it will return 28 Mar 2002 14:00:00.000; * If field is MONTH, it will return 1 Apr 2002 0:00:00.000. * * @param date Processing date, non-null * @param field threshold */
public static Date ceiling(final Object date, final int field)
/** * Builds a time range iterator based on the specified time focus and range type rangeStyle. * * If the time passed is Thursday, July 4, 2002, the range type is RANGE_MONTH_SUNDAY, Return the iterator from Sunday, June 30, 2002 to Saturday, August 3, 2002 * * @param focus specifies the time * @param rangeStyle range type, the value must be one of the following: * dateutils.range_month_sunday, * dateutils.range_month_monday, * dateutils.range_week_Sunday, * dateutils.range_week_monday, * dateutils.range_week_relative, * dateutils.range_week_center */
public static Iterator<Calendar> iterator(final Date focus, final int rangeStyle)
/** * Builds a time range iterator based on the specified time focus and range type rangeStyle. * * If the time passed is Thursday, July 4, 2002, the range type is RANGE_MONTH_SUNDAY, Return the iterator from Sunday, June 30, 2002 to Saturday, August 3, 2002 * * @param focus specifies the time * @param rangeStyle range type, the value must be one of the following: * dateutils.range_month_sunday, * dateutils.range_month_monday, * dateutils.range_week_Sunday, * dateutils.range_week_monday, * dateutils.range_week_relative, * dateutils.range_week_center */
public static Iterator<Calendar> iterator(final Calendar focus, final int rangeStyle)
/** * Builds a time range iterator based on the specified time focus and range type rangeStyle. * * If the time passed is Thursday, July 4, 2002, the range type is RANGE_MONTH_SUNDAY, * Return the iterator from Sunday, June 30, 2002 to Saturday, August 3, 2002 * * @param focus The value must be the */ listed in the iterator(Calendar, int) method comment
public staticIterator<? >iterator(final Object focus, final int rangeStyle)
/** * returns the number of milliseconds in the specified segment. All DateFields larger than the segment are ignored. * * Requesting any date millisecond will return the number of milliseconds of the current second (returning a number between 0 and 999). * Valid segment values are: Calendar.YEAR, Calendar.MONTH, calendar. DAY_OF_YEAR, * calendar. DATE, calendar. HOUR_OF_DAY, calendar. MINUTE, * Calendar.SECOND and calendar. MILLISECOND * with values less than or equal to MILLISECOND, 0 is returned. * * January 1, 2008 7:15:10.538 with Calendar.SECOND as Fragment will return 538 * January 6, 2008 7:15:10.538 with Calendar.SECOND as Fragment will return 538 * January 6, 2008 7:15:10.538 with Calendar.MINUTE as Fragment will return 10538 * January 16, MILLISECOND as fragment will return 0 * (a MILLISECOND cannot be split in milliseconds) * * @param Calendar retrieves calendar objects, non-null * @param fragment value */
public static long getFragmentInMilliseconds(final Calendar calendar, final int fragment)
/** * Returns the number of seconds in the specified segment. All DateFields larger than the segment are ignored. * * Requesting any date seconds will return the number of seconds of the current minute (returning a number between 0 and 59). * Valid segment values are: Calendar.YEAR, Calendar.MONTH, calendar. DAY_OF_YEAR, * calendar. DATE, calendar. HOUR_OF_DAY, calendar. MINUTE, * Calendar.SECOND and calendar.millisecond * returns 0 if the segment value is less than or equal to SECOND. * * January 1, 2008 7:15:10.538 with Calendar.MINUTE as fragment will return 10 * January 6, 2008 7:15:10.538 with Calendar.MINUTE as fragment will return 10 * January 6, 2008 7:15:10.538 with Calendar.DAY_OF_YEAR as Fragment will return 26110 * (7*3600 + 15*60 + 10) * January 16, 2008 7:15:10.538 with calendar. DAY_OF_YEAR as fragment will return 26110 * (7*3600 + 15*60 + 10) * January 16, 2008 7:15:10.538 with calendar. MILLISECOND as fragment will return 0 * * @param Calendar Non-null * @param fragment value */
public static long getFragmentInSeconds(final Calendar calendar, final int fragment)
/** * Returns the number of minutes in the specified segment. All DateFields larger than the segment are ignored. * * Requesting any date minute will return the number of minutes in the current hour (returning a number between 0 and 59) * Valid segment values are: Calendar.YEAR, Calendar.MONTH, calendar. DAY_OF_YEAR, * calendar. DATE, calendar. HOUR_OF_DAY, calendar. MINUTE, * Calendar.SECOND and calendar.millisecond * returns 0 if the segment value is less than or equal to MINUTE. * * January 1, 2008 7:15:10.538 with Calendar.HOUR_OF_DAY as fragment will return 15 * January 6, 2008 7:15:10.538 with calendar. HOUR_OF_DAY as fragment will return 15 * January 1, 2008 7:15:10.538 with Calendar.MONTH as Fragment will return 15 * January 6, 2008 7:15:10.538 with Calendar.MONTH as Fragment Will return 435 (7*60 + 15) * January 16, 2008 7:15:10.538 with Calendar.MONTH as Fragment will return 435 (7*60 + 15) * January 16, 2008 7:15:10.538 with calendar. MILLISECOND as fragment will return 0 * * @param Calendar Non-null * @param fragment value */
public static long getFragmentInMinutes(final Calendar calendar, final int fragment)
/** * returns the number of hours within the specified segment. All DateFields larger than the segment are ignored. * * Requesting any date hour will return the number of hours of the current day (returning a number between 0 and 23). * Valid segment values are: Calendar.YEAR, Calendar.MONTH, calendar. DAY_OF_YEAR, * calendar. DATE, calendar. HOUR_OF_DAY, calendar. MINUTE, * Calendar.SECOND and calendar.millisecond * segments with values less than or equal to HOUR_OF_DAY return 0. * * January 1, 2008 7:15:10.538 with Calendar.DAY_OF_YEAR as fragment will return 7 * January 6, 2008 7:15:10.538 with calendar. DAY_OF_YEAR as fragment will return 7 * January 1, 2008 7:15:10.538 with Calendar.MONTH as Fragment will return 7 * January 6, 2008 7:15:10.538 with Calendar.MONTH as Fragment will return 127 (5*24 + 7) * January 16, 2008 7:15:10.538 with Calendar.MONTH as Fragment will return 127 (5*24 + 7) * January 16, 2008 7:15:10.538 with calendar. MILLISECOND as fragment will return 0 * * @param Calendar Non-null * @param fragment value */
public static long getFragmentInHours(final Calendar calendar, final int fragment)
/** * Returns the number of days within the specified segment. All DateFields larger than the segment are ignored. * * Requesting any number of days will return the number of days in the current month (returning a number between 1 and 31). * Valid segment values are: Calendar.YEAR, Calendar.MONTH, calendar. DAY_OF_YEAR, * calendar. DATE, calendar. HOUR_OF_DAY, calendar. MINUTE, * Calendar.SECOND and calendar.millisecond * returns 0 if the segment value is less than or equal to DATE. * * January 28, 2008 with Calendar.MONTH as fragment will return 28 * February 28, 2008 with Calendar.MONTH as fragment will return 28 * January 28, 2008 with Calendar.YEAR as fragment will return 28 * February 28, 2008 with Calendar.YEAR as fragment will return 59 * January 28, 2008 with calendar. MILLISECOND as fragment will return 0 * * @param Calendar returns a Calendar object, non-null * @param fragment value */
public static long getFragmentInDays(final Calendar calendar, final int fragment)
/** * Intercepts the field values of two calendar objects to see if they are the same. * * @param cal1 First Calendar object, non-null * @param cal2 Second Calendar object, non-null * threshold in @param field Calendar */
public static boolean truncatedEquals(final Calendar cal1, final Calendar cal2, final int field)
/** * intercepts the value at field of two date objects. * * @param date1 First date object, non-null * @param date2 Second date object, non-null * @param field Calendar threshold */
public static boolean truncatedEquals(final Date date1, final Date date2, final int field)
/** * intercepts the value at field for comparing two calendar objects. * if the first calendar object is less than, equal to, or greater than the second calendar object, a negative integer, 0, or positive integer is returned * * @param cal1 the first calendar object, non-null * @param cal2 the second calendar object, Non-null * @param Field Calendar threshold */
public static int truncatedCompareTo(final Calendar cal1, final Calendar cal2, final int field)
/** * intercepts the value at field that compares two date objects. * if the first date is less than, equal to, or greater than the second, a negative integer, 0, or positive integer is returned * * @param date1 The first date object, non-null * @param date2 the second date object, Non-null * @param Field Calendar threshold */
public static int truncatedCompareTo(final Date date1, final Date date2, final int field)
// A simple example
System.out.println(DateUtils.addDays(new Date(), 1));//----------------- Current date. Days plus 1 if you want to suggest a negative number
System.out.println(DateUtils.addHours(new Date(), 0));//---------------- Current date
Date date = DateUtils.addDays(new Date(), 1);
Copy the code
DateUtils returns a Date that does not need to be converted. Of course, it is also a very old thing, but was born on the basis of Calender
Three, the date on which the JDK1.8 new API LocalDate | LocalTime | LocalDateTime
The new date apis are immutable and are more suitable for multi-threaded environments (fetching the current date and time from the system clock in the default time zone). Do not consider the time zone difference.
Java.util. Date starts from 0, we usually use +1, which is very inconvenient, java.time.LocalDate month and week are changed to enum
Java.util. Date and SimpleDateFormat are not thread-safe, while LocalDate and LocalTime are thread-safe and cannot be modified, just like the most basic String.
3. Java.util. Date is a “universal interface” that contains dates, times, and milliseconds to make it more specific
4. The reason why the new interface is better is that it takes into account date-time operations, which are often pushed forward or back by a few days. Using java.util.Date with Calendar is a lot of code to write, and the average developer may not get it right.
LocalDateTime (year, month, day, minute, second)
LocalDateTime date = LocalDateTime.now();
/ / the T10:2021-03-26 and. 009784900
System.out.println(date);
// Get year, month, day, hour, minute, second operation
System.out.println(date.getYear());
System.out.println(date.getMonthValue());
System.out.println(date.getDayOfMonth());
System.out.println(date.getHour());
System.out.println(date.getMinute());
System.out.println(date.getSecond());
System.out.println(date.getNano());
// Of course, you can also get any recent period of time
System.out.println(date.getSecond()+1); || System.out.println(date.getSecond()-1);
// Manually create a LocalDateTime instance
LocalDateTime date2 = LocalDateTime.of(2017.12.17.9.31.31.31);
System.out.println(date2);
// Add to get a new date instance
LocalDateTime date3 = date2.plusDays(12);
System.out.println(date3);
// Subtract to get a new date instance
LocalDateTime date4 = date3.minusYears(2); System.out.println(date4); IsAfter () determines whether a date is returned after the specified datebooleanType System. Out. Println (localDateTime isBefore (localDateTime. Now ()));/ / -- -- -- -- -- -- -- -- -- returns falseIsBefore () determines whether a date is returned before the specified datebooleanType System. Out. Println (localDateTime isAfter (localDateTime. Now ()));/ / -- -- -- -- -- -- -- -- -- returns falseIsLeapYear () returns a leap year (this is a method in the LocalDate class)booleanType System. Out. Println (localDateTime isEqual (localDateTime. Now ()));/ / -- -- -- -- -- -- -- -- -- returns true
Copy the code
(2) ToDate
Date to LocalDateTime
Date todayDate = new Date();
LocalDateTime ldt = Instant.ofEpochMilli( todayDate.getTime() )
.atZone( ZoneId.systemDefault() )
.toLocalDateTime();
System.out.println(ldt);
Copy the code
LocalDateTime to Date
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime localDate = LocalDateTime.now();
LocalDateTime localTime = LocalDateTime.now();
Date date = Date.from( localDateTime.atZone( ZoneId.systemDefault()).toInstant());
Date date2 = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
Date date3 = Date.from(localTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()).toInstant());
System.out.println(date);
Copy the code
LocalDateTime LocalDateTime LocalDateTime LocalDateTime LocalDateTime LocalDateTime LocalDateTime LocalDateTime
Hutool (Java Tool Class Library)
A more fun Java tool class library, including a lot of fun tool classes, simple and convenient.
(1) Installation
Maven
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.61.</version>
</dependency>
Copy the code
Gradle
compile 'cn. Hutool: hutool -all: 5.6.1'
Copy the code
Maven central repository Hutool 5.x supports JDK8+. There is no test for Android, so there is no guarantee that all tool classes or tool methods will be available. If your project uses JDK7, use Hutool version 4.x
(2) Use
Println (dateutil.now ())); system.out.println (dateutil.now ()); / / -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- take the current time This has nothing to say to download the source code to see Chinese annotation can, not for one by one,,, simple.Copy the code
conclusion
In short, fun tool class a big pile, whether JDK native or others package tool class, if you want to also can own through JDK1.8 date API package belongs to their own date tool class, online date tool class too much, do not duplicate wheel ~~~~~~~~~~ today is full of energy