My app sends the date in milliseconds to a WS. Upon receiving it, I convert it to date format in the WS, but it appears to me with differences with respect to the initial value.
I decided to send the date in string format and as my logic in the app always uses the date in milliseconds, it seemed correct to create a method to return the date in string.
The problem I have is that he always returns me with a wrong month. I have tried to use DateUtil, but can't find a way to apply it.
My method is as follows and I appreciate the support.
public static String cambiaNumeroFecha(Long fecha) {
Calendar c = Calendar.getInstance();
Date d = new Date(fecha);
String r = Integer.toString(c.get(Calendar.YEAR)) + "-"
+ Integer.toString(c.get(Calendar.MONTH)) + "-"
+ Integer.toString(c.get(Calendar.DAY_OF_MONTH));
return r;
}