Java8 In addition to the lambda expression on the time and the array of these two commonly used APIs should be adjusted,
Stream has several common functions:
Store sort (A, a, b) A.compareto The result is a positive order, from small to large if (a, B)->b.compareto (a) out of the result is from large to small
Filter intercept, filter. Filter by condition
Foreeach iterate over each element
Map Change or replace
Limit length or number of compliance limits
Skip jumps to a start point, and the skip and limit combinations can create pagination effects
Sum, Count is the general aggregation parameter
Distinct de-duplication, the deduplication comparison here is whether two objects are equal Object.equal (object). Cannot be implemented according to a field property to go to weight. Of course, it doesn't fit the normal logic.
PS: The cycles required for these combinations are one-time, highly efficient
JAVA8 API for Date time
1 //Update for JAVA8 time API2Clock clock=CLOCK.SYSTEMUTC ();3 System.out.println (Clock.millis ());4 //Time Line Instant5Instant Instant =Instant.now ();6Thread.Sleep (1000);7Instant end =Instant.now ();8 //Time interval Duration9Duration duration=Duration.between (instant, end);TenSystem.out.println ("This time:" +Duration.tomillis ()); One //Local date no time and seconds ALocaldate localdate=Localdate.now ();
Temporalajusters Time Arithmetic -Localdate localdate1= Localdate.with (Temporaladjusters.dayofweekinmonth (2, Dayofweek.friday)); - System.out.println (localDate1); the //Custom Date Orthotics Use the Plus* method to make it easy to run time
- -Temporaladjuster Next_workday = W, {//Custom Corrector -Localdate resultdate =(Localdate) W; + Do { -Resultdate = resultdate.plusmonths (1). Plusdays (-1); +} while(Resultdate.getdayofweek (). GetValue () >= 6); A returnresultdate; at }; - -Localdate LocalDate2 =Localdate1.with (next_workday); -System.out.println ("Next month's time" +localDate2); - //time format, the key is local time!! With sometimes a few seconds. -LocalDateTime LocalDateTime =Localdatetime.now (); inSystem.out.println ("Time Type:" +datetimeformatter.oflocalizeddatetime (formatstyle.medium). Format ( -LocalDateTime));//language-dependent format time format conversion also package is better. to +System.out.println ("Time Type:" +datetimeformatter.ofpattern ("Yyyy/mm/dd hh"). Format ( -LocalDateTime));
Changes in time and data in Java8