20145317 Peng Yao "Java Program Design" 7th Week study Summary

Source: Internet
Author: User

20145317 Peng Yao "Java Program Design" 7th Week study summary textbook study content summary 13th time and date

13.1.1 Measurement of Time
• Even if the label is GMT (Greenwich Mean Time), it actually refers to UTC (Unix time).
• The units of the second are defined based on the Tai. That is, the number of vibrations emitted by cesium atoms.
· UTC takes into account that the rotation of the earth is slower and has a leap-second correction, ensuring that UTC differs from UT by no more than 0.9 seconds. The last leap second was fixed to June 30, 2012.
· Unix time is January 1, 1970 00:00:00 for the beginning of the second pass through the description, regardless of leap seconds, many UNIX systems, platforms, software, etc., all choose this time as the starting point of time expression.

About 13.1.2 Almanac

• Julian calendar: Fixed a leap year in the Roman calendar three years, and a leap for four years.
• Gree Calendar: The day of the Julian calendar Thursday, October 4, 1582, is scheduled for the Gregorian calendar October 15, 1582 Friday.
· ISO 8601 Standard, using a unified data format such as: YYYY-MM-DDTHHH:MM:SS.SSS, etc.

13.1.3 recognize time zones

UTL Offset
Daylight Saving Time: Also known as summer Time, is basically on the first day of implementation, allowing the day time to increase by an hour, and the last day after the end of the adjustment an hour back.

13.2.1 the instantaneous date on the timeline

• If you want to get system time, one way is to use the System.currenttimemillis () method to return a long integer representing the number of milliseconds since January 1, 1970 0:0 0 seconds 0 milliseconds.
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()); }}

13.2.2 Formatting the time date DateFormat

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/(24*60*60* 1000l)); }} 

Calendar for 13.2.3 processing time date

· Date is recommended as an instantaneous representation on the timeline, to format the time date through DateFormat, and if you want to get a time-date information, or to manipulate the time-date, you can use the calendar.
• To create a calendar instance, you can use the Get () method and specify the fields on the calendar. Use the Add () method to adapt the time, using the roll () method to only add to a field in the date.

13.2.4 Setting TimeZone

• When using calendar, the time zone information is not used, this is the default time zone, and you can use Java.util.TImeZone's Getdefault () to get the default time zone information
• The available ID can be obtained using timezone.getavailableids () and it will return string[]

13.3.1 API for machine time view

• Because a time zone has not been implemented daylight savings for a while, many developers do not know that there has been daylight saving time, after acquiring the date instance, by the name date misleading them to represent the date, so should not use the data instance to know the human point of view time information.
• Truly reliable information is only included in the epoch number of 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.

13.3.2 API for Human time perspective

· LocalDateTime only includes time and date, localdate only dates, localtime only time, they are all about time, no time zone information.
• If time zone information is required, zonedatetime and Offsetdatetime can be based on the three time periods described above.

13.3.3 the operation of time

1.TemporalAmount

The time difference is defined by duration, and the date difference is defined period.

2.TemporalUnit

The Between () method is used to calculate the time difference

3.Temporal

4.TemporalAccessor defines a read-only time object

Learning progress Bar /Cumulative) new/cumulative)
lines of code (newBlog volume (Learning time (new/cumulative) Important growth
Goal 5000 rows 30 Articles 400 hours
First week 100/100 1/2 20/20
Second week 250/350 1/3 20/40
Third week 500/850 1/4 25/65
Week Four 500/1350 1/5 20/85
Week Five 550/1900 1/6 20/105
Week Six 600/2500 1/7 20/125
Seventh Week 500/3000 1/8 20/145
Resources
    • Java Learning Notes (8th Edition)
    • Java Learning Note (8th Edition) Learning Guide
    • ...

20145317 Peng Yao 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.