Ljdawson Ljdawson - 1 year ago 65
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?


Answer Source

You can do something like:

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

TextView footer = findViewById(R.id.footer);
footer.setText("" + year);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download