O'Reilly logo

Mastering Android Wear Application Development by Javeed Chida, Siddique Hameed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The DayOfYearActivity class

The DayOfYearActivity activity is a very simple class that uses Java's default java.util.Calendar instance to calculate how many days have passed and how many days are remaining until the end of the year:

import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import java.util.Calendar; public class DayOfYearActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_day_of_year); Calendar calendar = Calendar.getInstance(); String dayOfYearDesc = getString(R.string.day_of_year_card_desc, calendar.get(Calendar.DAY_OF_YEAR), calendar.getActualMaximum(Calendar.DAY_OF_YEAR) - calendar.get(Calendar.DAY_OF_YEAR)); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required