<>java.util.Date

<> time zone

GMT(Greenwich Mean Time) For Greenwich mean time , You know that .

and CST But it can also represent the following 4 Different time zones :

* Central Standard Time (USA) UT-6:00
* Central Standard Time (Australia) UT+9:30
* China Standard Time UT+8:00
* Cuba Standard Time UT-4:00
<>java.util.Date Basic use

<> initialization
Date date = new Date(); Date date1 = new Date(1000L); // Create a local time by default , long type //
Date date = new Date(System.currentTimeMillis()); // from 1970-1-1 0:0:0 start
<> Output time
System.out.println(date1); // Print out Beijing time Thu Jan 01 08:00:01 CST 1970 System.out.
println(date1.toGMTString()); // Print out of grid standard time 1 Jan 1970 00:00:01 GMT
<> Output time difference
// Time difference between return time and green time , Time in minutes , nothing less than 8 Hours , Output of this function -480 Beijing time -480 Minutes equals green time date1.
getTimezoneOffset();
<> Printing milliseconds
long m = date1.getTime(); // Print out date reach 1970 year 1 month 1 Milliseconds per day System.out.println("m = " +
m);
<> Compare time
// Compare time // return boolean type date.after(date1); date.before(date1); // return -1 1 0 date.
compareTo(date1);
<>java.util.Date Subclass of

<>java.sql.Date Use of
// sql Packaged date class , Receive a millisecond value java.sql.Date sqldate = new java.sql.Date(1000L); //
Output a string like this 1970-01-01 System.out.println(sqldate); // Convert to green time and util in date Same output
System.out.println(sqldate.toGMTString());
<>java.sql.Timestamp use
java.sql.Timestamp timestamp = new Timestamp(2000L); // Local time returned //1970-01-01
08:00:02.0 //1970-01-01T08:00:02 System.out.println(timestamp); System.out.
println(timestamp.toLocalDateTime()); // Return a green instantaneous time // 1970-01-01T00:00:02Z
System.out.println(timestamp.toInstant());
<>java.sql.Time use
java.sql.Time time = new Time(3000L); // Returns a local time without a date 08:00:03 System.out.
println(time);
<>SimpleDateFormat use
Date date = new Date(); // Specify format output time // yyyy year MM month dd day h 12 Hour system H 24 Hour system 0-23 ss second
SSS millisecond DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
System.out.println(dateFormat.format(date)); // Converts a string of the specified format to Date // "2018-05-26
09:03:22.658" DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss.SSS"); try { date = dateFormat1.parse("2018-05-26 09:03:22.658"); //
output date = Sat May 26 09:03:22 CST 2018 System.out.println("date = " + date); }
catch (ParseException e) { e.printStackTrace(); }
<>Calender use

GregorianCalendar Class contains national standard calendars
Calendar calendar = new GregorianCalendar(); // Set calendar time calendar.set(Calendar.
YEAR, 2019); calendar.set(Calendar.MONTH, 5); calendar.set(Calendar.DAY_OF_MONTH
, 26); // use Date Class settings calendar time calendar.setTime(new Date()); // Get calendar time
calendar.getTime(); Return to a Date object // output Wed Jun 26 12:58:42 CST 2019 System.out.
println(calendar.getTime().toString()); // Use calendar to get time offset // output Tue Jun 26 12:58:42
CST 2029 calendar.add(Calendar.YEAR, 10); System.out.println(calendar.getTime().
toString());
<>java8 New features —java.time package Time processing class

<>LocalDate class
// Local date LocalDate localDate = LocalDate.of(2019, 2, 14); System.out.println(
localDate); int year = localDate.getYear(); // That year System.out.println("year = " +
year); Month month = localDate.getMonth(); // Months System.out.println("month =
" + month); int dayOfMonth = localDate.getDayOfMonth(); // Day of the month System.out.
println("dayOfMonth = " + dayOfMonth); DayOfWeek dayOfWeek = localDate.
getDayOfWeek(); // Day of the week System.out.println("dayOfWeek = " + dayOfWeek); int
lenth= localDate.lengthOfMonth(); // Days of a month System.out.println("lenth = " +
lenth); boolean leapYear = localDate.isLeapYear(); // Leap year or not System.out.println(
"leapYear = " + leapYear); // Get current date System.out.println("LocalDate.now() = " +
LocalDate.now());
<>LocalTime class
// LocalTime Include specific time LocalTime localTime = LocalTime.of(22, 10, 59); System.out.
println("localTime = " + localTime);
<>LocalDateTime class
// LocalDateTime include LocalDate and LocalTime LocalDateTime localDateTime =
LocalDateTime.of(localDate, localTime); System.out.println("localDateTime = " +
localDateTime); //LocalDateTime and LocalDate, LocalTime Mutual conversion LocalDate localDate1
= localDateTime.toLocalDate(); LocalTime localTime1 = localDateTime.toLocalTime(
);
<>Instant class
// A timestamp Instant instant = Instant.now(); System.out.println("instant = " +
instant);
<>Duration class
// A time period Duration duration = Duration.between(localDateTime, localTime1); long
toDays= duration.toDays(); // How many days are there in this period long toHours = duration.toHours(); //
There are several hours in this period // adopt of Create time period Duration duration1 = Duration.of(5, ChronoUnit.DAYS);
<>Period class
// Time period in MM DD YY Period period = Period.between(localDate, localDate1);
<> Time addition and subtraction
// Time addition and subtraction LocalDate date = LocalDate.now(); LocalDate localDate2 = date.
minusDays(5); LocalDate localDate3 = date.plusYears(10); date.plus(5, ChronoUnit
.DAYS); System.out.println("localDate3 = " + localDate3); System.out.println(
"localDate2 = " + localDate2);

Technology
©2019-2020 Toolsou All rights reserved,
Unity Scene loading asynchronously ( Implementation of loading interface )ESP8266/ESP32 System : Optimize system startup time vue Of v-if And v-show The difference between JS How to operate college examination for the self-taught An overview of Marxism Faster RCNN Explanation of series algorithm principle ( note )CSS architecture design NOI2019 travels IAR Installation and use tutorial sort ( one ) bubble sort