I have one problem with android calendar programming, so
If there are 2 months on one week, android write me name of old month. I want him to write something like (old month-new month).
My Code is as follows
Calendar wek = Calendar.getInstance(Locale.US);
wek.add(Calendar.WEEK_OF_YEAR,r);
SimpleDateFormat gm = new SimpleDateFormat("MMM yyy");
mes.setText(gm.format(wek.getTime()));
The reason it does this is because when looking at a date represented by a week, it only looks at the first day in the week. You’d need to manually check first and last days of the week and, if they are in a different month, then format the date manually. You also need to be careful about the week overlapping the years as well. Something like this: