Intelligent Curriculum for Android-Implementation of school year term week

Source: Internet
Author: User

 

The last time we realized the dynamic display of date and time, this time we achieved the display of the school year, semester, week ,:

The first is the display of the school year term:

Calendar c = Calendar. getInstance ();

Int year = c. get (Calendar. YEAR );

Int month = c. get (Calendar. MONTH) + 1; // The month value obtained by the Calendar object is the actual MONTH value minus 1

If (2 <month & month <8)

{

Textview02.setText (year + "--" + (year + 1 ));

Textview03.setText ("second semester ");

}

Else if (month <= 2)

{

Textview02.setText (year-1) + "--" + year );

Textview03.setText ("first semester ");

}

Else

{

Textview02.setText (year + "--" + (year + 1 ));

Textview03.setText ("first semester ");

}

Generally, the year February to the year August is the second semester from the current academic year to the next academic year. At the beginning, I think the remaining months are the first semester from the current year to the next academic year, however, it is found that the month of the current year is January, although it is the first semester, but get (Calendar. YEAR) is the next year, so if (month <= 2), setText (year-1) + "--" + YEAR );

The following is the weekly display: because the value of the week obtained by the Calendar Object is: Sunday is 1, Monday is 2, and so on, so:

Calendar c = Calendar. getInstance ();

Int day = c. get (Calendar. DAY_OF_WEEK );

Switch (day ){

Case 2:

Textview05.setText ("Monday ");

Break;

Case 3:

Textview05.setText ("Tuesday ");

Break;

Case 4:

Textview05.setText ("Wednesday ");

Break;

Case 5:

Textview05.setText ("Thursday ");

Break;

Case 6:

Textview05.setText ("Friday ");

Break;

Case 7:

Textview05.setText ("Saturday ");

Break;

Default:

Textview05.setText ("Sunday ");

Break;

}

The final display effect is:

Because weekly display involves data storage, because we need to first obtain the time value of Monday in the first week of the current school year, and then create a database table and store it in the database, therefore, we do not calculate the number of times per week for the time being.

In addition, because both the school year and the week have to change dynamically, we should also put them in the last Runnable class run () method.

 


From the tianshuguang Column

Related Article

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.