Ljdawson Ljdawson - 4 months ago 7
Android Question

Inserting the current year into a TextView

Just a small problem really, I want to place the current year into the footer of my apps. Each footer is a TextView, which is seen on menu screens etc. Is there a way to insert the year into this dynamically?

Cheers,
Laurence

Answer

You can do something like:

Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);

TextView footer = findViewById(R.id.footer);
footer.setText("" + year);