I'm in a bit of a pickle. I'm building an application where I display the Day, Month, Year and Week Number from a DatePicker. When a date is selected, the date and the week number should then be displayed on screen. I've managed to display the correct date, but I struggle to display the Week Number
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView bottomNav = findViewById(R.id.bottom_navigation);
bottomNav.setOnNavigationItemSelectedListener(navListener);
datePicker = (DatePicker) findViewById(R.id.kalender);
datoText = (TextView) findViewById(R.id.kalenderText);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
final int week = calendar.get(Calendar.WEEK_OF_YEAR);
datePicker.init(year, month, day, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String dato = dayOfMonth + " / " + (monthOfYear + 1) + " / " + year;
datoText.setText(dato);
}
});
So, my question is this: How can I display the week number of the selected date?