20145207 Java programming 7th Week of study summary

Source: Internet
Author: User
Tags date1 dateformat epoch time iso 8601 time and date

Summary of learning contents of textbook

First, Lambda

-Use the lambda feature to remove duplicate information to get the syntax concise and to increase the expression of the program code. The lambda expression itself is neutral and does not represent any type of instance, and the same lambda expression can be used to represent object operations of different target types. If the local variable captured in the lambda expression is itself equivalent to the final local variable, you can not add final to the local variable. However, it is not possible to change the value of a captured local variable in a lambda expression. The actual type of lambda expression depends on the interface of the function and can define the interface itself, but for several commonly used function interface behaviors, JDK8 has given a definition. According to the behavior, can be divided into four types of consumer,function,predicate,supplier. One of the purposes of JDK8 's introduction of Lambda is to make it easier for developers to write programs, and the concept of "divide and conquer" is the precondition for accessibility. The 13th chapter introduces a lot of time benchmarks, with our familiar GMT, and the epoch time I first knew, and so on. Epoch is the beginning of a particular era, an instant on the timeline. JDK8 the most important thing in the new time and date processing API is the clear distinction between machine-to-time concepts and human concepts that make boundaries distinct.

The code in the textbook:

    • P429 examples are as follows:
Package CH7;/** * Created by Administrator on 2016/4/16. */import java.util.*;  Import static java.lang.system.*;  Public class Datedemo { public static void Main (string[] args) { date date1 = new date ( Currenttimemillis ()); Date date2 = new date (), Out.println (Date1.gettime ()); Out.println (Date2.gettime ())   ;}} 
    • The responsibility for the processing of the string time format falls to Java.text.DateFormat. It can be formatted by various static methods of Dateform, and can also be customized using pattern strings. The parse () method to parse the specified string into a date instance.
Package CH7;/** * Created by Administrator on 2016/4/16. */import Java.util.*;import java.text.*;PublicClassHowold {PublicStaticvoid Main (string[] args) throws Exception {System.  Out.print ("Enter Birth date (YYY-MM-DD):"); DateFormat DateFormat = new SimpleDateFormat ("Yyy-mm-dd"); Date birthDate = Dateformat.parse (new Scanner (System.  IN). Nextline ()); Date currentdate = new Date (); Long life = Currentdate.gettime ()-birthdate.gettime (); System. out.println ("Your Age this year is:" + (life/(365*24*60*60*1000L     ));}} 
Ii. measurement of time and date Time 1. Greenwich Mean Time

Greenwich Mean time, often referred to as GMT, is initially referred to the standard solar time from the Greenwich Royal Observatory, at midday of Greenwich Standard Time, when the sun reaches the highest point in the sky, GMT time is often considered as UTC time in a less rigorous manner.

2. The GMT

By observing the distant stars crossing the Meridian, the Earth's rotation speed is affected by the error.

3. International Atomic Time (TAI)

The international unit of the second is defined as the time spent on the radiation vibrations of cesium atoms for 9,192,631,770 weeks.

4. World Coordination Time (UTC)

Keep the Tai and UT time errors not too large with leap seconds correction.

Calendar introduction 1. Julian calendar

Fixed a leap year in the Roman calendar three years, and a leap for four years.

2. Gregorian Calendar

Reformed the Julian calendar.

3.ISO 8601 Standard

Adopt a unified data format.

JDK8 New Time date API1. Machine Time View API

The truly reliable information only contains the epoch milliseconds. You can also use the static method of instant now () to get an instant instance representing the number of milliseconds in the Java epoch.

2. Human time (ISO8601 standard)

1.LocalDateTime: Includes date and time.

2.LocalDate: A datetimeexception error is thrown when a date is set to a date that does not exist.

3.LocalTime: Only time.

4.ZonedDateTime: Zoneddatetime automatically corrects when time-zone information is not actually present when it is combined.

Last week's summary of the wrong quiz
    • Which of the following commands can copy F1.txt to F2.txt?

A. CP F1.txt F2.txt

B. Copy F1.txt F2.txt

C. Cat F1.txt > F2.tx

D. CP F1.txt | F2.tx

E. Copy F1.txt | F2.tx

Resolution : Select a, C. Becausecopy f1.txt f2.txt

is to copy the contents of the F1 into the F2.

    • The interrupt () method of the calling thread throws () the exception object?

A. IOException

E I IllegalStateException

C. RuntimeException

D. Interruptedexception

E. SecurityException

Resolution : Select D, E.

Problems in teaching materials learning and the solving process

The content of this chapter is really provincial, and there are a lot of new things, but in the understanding, there is no previous conceptual knowledge difficult to understand, in the book code after a bit, for these things have a good understanding, but the book is still a lot of knowledge, p433 code, because the date of writing, There will be a small error, and no mention of his birthday, but the calculation will be a year old.

Problems in code debugging and the resolution process

Problem: The main class could not be found or could not be loaded

Javac when compiling code, be sure to add the-D parameter

may not look serious enough, did not find any problems, but also need more practice.

20145207 Java programming 7th Week of study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.