20145301 Seven weeks Study summary

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

20145301 the summary of the learning contents of the seven Week learning summary textbook
  • The measure of time GMT, referred to as GMT time, is obtained by observing the sun; when the world, UT; international atoms, TAI; World coordination Time, Utc;unix time, the number of seconds elapsed from January 1, 1970 00:00:00 as the starting point, regardless of the leap second correction; epoch, The number of milliseconds elapsed from January 1, 1970 00:00:00 to the starting point.

  • Introduction of the Almanac Julian Calendar, four years a leap; the Gregorian calendar reformed the Julian calendar; the ISO 8601 standard is mostly the same as the Gregorian calendar in the data definition. Recognize daylight saving time in time zones.

  • Date uses the gettime of the date instance to obtain the epoch milliseconds, the **data instance is used only as a moment on the timeline, and the string format can be processed using DataFormat, respectively getdateinstance, Gettimeinstance, Getdatetimeinstance

  • DateFormat Java.text.DateFormat string time format processing, DataFormat is an abstract class, its operation class is java.text.simpledataformat,getdatainstance (), Static usages such as gettimeinstance (), getdatatimeinstance (), or Simpledataformat instances can be built directly, or using DataFormat, directly building SimpleDateFormat, You can customize the string format the parse method can dissect a specified string into a date instance

  • Calendar Calendar instance to obtain a time date information, or to operate on the time and date; Calendar is an abstract class, Java.util.GregorianCalendar is its subclass, through the calendar getinstance () to obtain the calendar instance, the default is to obtain the GregorianCalendar instance; Compare two calendar time and date successively, use after () or before () method; After getting the calendar instance, you can get the date information, can be set, can be used to change the operation.

  • TimeZone TimeZone Getdefault can obtain the default time zone information; Calender can specify timezone when calling getinstance (), and if a calender instance has been obtained, the time zone can be set by means of Settimezone ().

  • The API date instance of the machine time view represents only the time information of the machine view; The static method of using instant now () Gets the instant instance, Ofepochmilli () can specify the Java epoch milliseconds, ofepochsecod () specify the number of seconds After obtaining the instant instance, you can use Plussecond (), Plusmillis (), Plusnanos (), Minusseconds (), Minusmillis (), Minusnanos () to do the operation on the timeline, Returns a new instant instance that represents the time after the operation.

  • The API date instance of the human time view represents only the time information of the machine point of view, which can be supplemented on the basis of the above classes, such as the enum type, the number representing the month, and the month to be obtained by the GetValue () method. Instead of using the Oridinal () method.

  • Temporalamount time measurement, new time and date are defined using the API class duration, for year, month, day, week date difference, can use period class definition, static method Ofdays (), Ofmonths (), Ofweeks (), Returns a period instance.

  • Another overloaded version of the Temporalunit Plus () method, which accepts Java.time.temporal.TemporalUnit instances, Java.time.temporal.ChronoUnit is actually doing the class, using the enum to do it. Temporal plus () is defined on the temporal interface, Instant, Localdate, LocalDateTime, Locattime, Offsettime, zoneddatetime, etc., all operated temporal Interface.

  • Temporalaccessor Temporal is a sub-interface of Temporalaccessor. The annual calendar system design DK8 uses a calendar system design, which means that the class in the Java.time suite uses a single ISO8601 calendar system when the calendar system needs to be implemented. Classes that require explicit implementation of the Java.time.chrono.Chronology interface.

Problems and solutions in teaching materials learning this chapter is basically able to understand the problems in code debugging and solve the process problems P441 temporalamout below the code

The resolution process enters the code as required and indicates the class name of the Ofpattern

The result shows an error, but does not understand the cause of the error

Try to comment out the ofpattern sentence.

Can be successfully passed, if you use SimpleDateFormat method to replace the Ofpattern in the code

No, the result shows that the Object cannot be converted to Date

Then try the Calendar to re-express

Finally, there is a success.

10.2 Character Processing class
  • Packet java.io in the two classes reader and writer, they are able to write byte stream in a character stream of the object, so the character stream is essentially in reader and writer encapsulated byte stream. Both reader and writer are abstract classes, and all two classes implement the Autocloseable interface that declares the close () method.

  • Reader and writer classes, and their subclasses themselves, are not streams, but they provide methods that can be used to read and write the underlying stream as a stream of characters. Therefore, the underlying InputStream and OutputStream objects are typically used to create reader and writer objects.

    11th chapter-Threading with parallel API11.1 threads
  • A thread can have multiple processes, that is, a multithreaded program that, if it wants to establish a process independently of main (), can compose a class operation Java.lang.Runnable interface, where the entry point of the process is operations in the run () method, and the process starting with main () is executed by the main thread. Creates a thread instance to execute the run () method defined by the Runnable instance, and to start the thread execution of the specified process, the start () of the thread instance must be called. Thread and Runnable define the process in the Runnable run () method, inherit the thread class, and redefine the run () method.
  • Thread life cycle a thread is marked as a daemon thread, and the JVM terminates automatically at the end of all non-daemon threads, using the Setdaemon () method to set whether a thread is a deamon thread, using the Isdaemon () method to determine whether a thread is Deamon thread By default all threads that are generated from Deamon threads are also deamon threads;
  • Use the thread's SetPriority () method to set the priority, 1-10, the default value is 5 let the thread into the blocked state, call Thread.Sleep () and other methods, waiting for input/output thread input/output into the blocked state, in the completion of input/ After the output, it returns to the Runnable state; join () joins the thread into the process of the other threads; After the thread finishes the run () method, it enters dead and the thread that enters dead cannot call the start () method again.
  • Threadgroup threads cannot be replaced once they are grouped into a group; Java.lang.ThreadGroup can manage threads in a group; The interrupt () method can break all threads in the group;
  • The Setmaxpriority () method can set the maximum priority for all threads in a group; The enumerate () method can get all the threads in the group at once; Activecount () method gets the number of threads in the group; The Uncaughtexception () method handles an exception that is not caught by a thread. Synchronized and volatile blocks marked as synchronized will be monitored, and any thread that executes the block must first acquire the specified object lock, the thread attempts to execute the synchronized chunk and enters the Blocked, and after the lock is taken, Will go back to the runnable state, waiting to be discharged into the runnning state, the synchronized required to achieve the mutex of the marked block, and visibility, declare volatile on the variable, indicating that the variable is unstable, volatile, may be accessed under multiple threads, to ensure the visibility of the variable.
  • In Java, if you want to design a process independently of main (), you can compose a class operation Java.lang.Runnable interface, where the entry point of the process is the operation in the run () method. If you want to add a CPU to the JVM, that is to create a thread instance, to start the extra CPU is to invoke the start () method of the thread instance, and the additional CPU execution process entry point can be defined in the run () method of the Runnale interface.
  • The advantage of manipulating the runnable interface is that it is more resilient, and your class has the opportunity to inherit other classes. If the thread is inherited, then the class is a thread, usually in order to directly take advantage of some of the methods defined in thread to inherit the thread. 11.2 Parallel APIs
  • Lock: The implicit lock object relative to the thread model, lock provides an explicit lock operation to simplify the application. Executors: Provides a set of HIGHLEVELAPI for performing and managing parallel tasks.
  • Concurrentcollections: Contains a set of data structures that support parallel processing, greatly simplifying the difficulty of parallel programming. Atomicvariables: Reduces synchronization operations and avoids data inconsistencies. Fork/join Framework: Provides support for process operations.
  • The Readwritelock interface defines the read lock and write lock behavior, and you can return the lock operand using the Readlock (), Writelock () method. Reentrantreadwritelock is the primary operation class for the Readwritelock interface, and the Readlock () method returns the Reentrantreadwritelock.readlock instance, Writelock () Breaking the law will return the Reentrantreadwritelock.writelock instance.
  • The condition interface is used with lock, and the most basic usage is to achieve the function of the Wait (), notify (), Notifyall () method of object. The await (), signal (), Signalall () methods of condition can be considered as corresponding to the wait (), notify (), and Notifyall () methods of object.
Other

Multiple threads created with the extended thread class, while executing the same code, are independent of each other and have their own resources, without interfering with each other.

Experience

The two chapters of learning feel more difficult to understand, need more extension study and their own practice to come in-depth understanding, simple reading is far from enough.

Learning progress Bar
Target number of lines of code Blog Volume Study Time Important Growth
Goal 4000 rows 30 Articles 400 hours ----
First week 100/4000 2/30 15/400 Hello Java
Second week 350/4000 3/30 40/400 Process Control
Third week 500/4000 4/30 50/400 Classes and objects, encapsulation
Week Four 700/4000 5/30 70/400 Inheritance, interfaces
Week Five 950/4000 6/30 90/400 Exception and resource management
Week Six 1200/4000 8/30 120/400 Input/Output
Resources
    • "Java Learning Notes"
    • Learning Guide for Java Learning notes
    • Bi Xiangdong Java Teaching

20145301 Seven weeks 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.