2015:wps written-android Development post

Source: Internet
Author: User

The topic altogether three:

One: implement a function that can determine the relationship of two straight lines: parallel, coincident, perpendicular, or intersecting.

Two: implement a function, you can get any two days apart.

Three: for the title one or topic two, to achieve a complete unit testing.

(after the written test on the internet to search for last year's topic, unexpectedly exactly the same, exactly the same ...) The importance of the brush problem can be seen. )


Topic One: (occupied pits)

Topic Two:

At that time only the most basic judgment, that is, the number of days separated by the number of years *365+ months * (31/30/28/29) + days apart.

Unfortunately, the leap year algorithm is written wrong ...

  1. to determine whether a year is a leap years, follow these steps:
    1. If the year can be divisible by 4 , perform step 2, otherwise follow step 5.
    2. If the year can be divisible by 100 , perform step 3, otherwise Follow step 4.
    3. If the year can be divisible by 400 , perform step 4, otherwise Follow step 5.
    4. This is a leap year (with 366 days).
    5. This is not a leap year (with 365 days).
    leap Year algorithm:(year%4==0&&year%100!=0) | | (year%400==0)  

Optimization:

(Date1.gettime ()-date2.gettime ())/ -* -* -* +  

So the number of days to get is not very accurate, such as yesterday's 10 points, to today some time calculated may not be a day, but actually the interval of days does not need specific time, so need to zero time to calculate.

public          Static Long Getdaysbetween (Date startdate,date endDate) {Calendar Fromcalendar = calendar.getinstance ();          Fromcalendar.settime (StartDate);          Fromcalendar.set (calendar.hour_of_day, 0);          Fromcalendar.set (calendar.minute, 0);          Fromcalendar.set (Calendar.second, 0);                    Fromcalendar.set (Calendar.millisecond, 0);          Calendar Tocalendar = Calendar.getinstance ();          Tocalendar.settime (endDate);          Tocalendar.set (calendar.hour_of_day, 0);          Tocalendar.set (calendar.minute, 0);          Tocalendar.set (Calendar.second, 0);            Tocalendar.set (Calendar.millisecond, 0);  Return (Tocalendar.gettime (). GetTime ()-Fromcalendar.gettime (). GetTime ())/(1000 * 60 * 60 * 24); }

Topic Three:(occupy pit)

2015:wps written-android Development post

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.