Good afternoon, help me figure out how to convert the calendar, when I convert the calendar and the current time it returns a day more, and the month and year are all correct?

enter image description here

Here is the code that I use to convert the date, month and year:

GregorianCalendar cse = new GregorianCalendar(); cse.setTimeInMillis(Long.parseLong(cursor.getString(cursor.getColumnIndex(KEY_PUBDATE)))); // дата новости cse.add(Calendar.DAY_OF_MONTH, 1); SimpleDateFormat fmt = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss Z", Locale.ENGLISH); String dateString = fmt.format(cse.getTime()); Log.d("DMC6", "dateString " + dateString ); holder.textPubData.setText(dateString); 
  • one
    Most likely, you need to add a time zone (TimeZone). - Ksenia
  • 6
    So in your code: cse.add(Calendar.DAY_OF_MONTH, 1); what do you expect? - Vartlok 2:21 pm
  • Thanks Vartlok). - D.Dante
  • @Vartlok please reply. - andreycha

1 answer 1

You have a line in your code:

 cse.add(Calendar.DAY_OF_MONTH, 1); 

If you look at the documentation :

The Adds The Calculator

Those. your code itself adds to the value one day, which bothers you.