Well, Im working on Android and I got a date in String format from JSon with format : "dd-MM-yyyy", and date today from system, so I cant to get the diference between two dates. I did it.
SimpleDateFormat df1 = new SimpleDateFormat("dd-MM-yyyy",java.util.Locale.getDefault());
String fechaActual = df1.format(c.getTime());
System.out.println("=========> Date Today => "+fechaActual);
fechaEvaluacion = json_data.getString("fechaEvaluacion");
Date fechaEvDate = Date.valueOf(fechaEvaluacion);
long fechaInicial = fechaEvDate.getTime();
long fechaFinal = xDate.getTime();
long diferencia = ( fechaFinal- fechaInicial );
final long days = diferencia / 24;
System.out.println("The difference between the two days is: "+days);
if(days < 3){
runOnUiThread(new Runnable() {
public void run() {
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(200);
Toast toast2 = Toast.makeText(getApplicationContext(), "Tienes "+tipoEvaluacion+" de: "+nombreAsignatura+" en "+days+", el día: "+fechaEvaluacion, Toast.LENGTH_LONG);
toast2.setGravity(Gravity.TOP|Gravity.RIGHT, 0, 0);
toast2.show();
}
});
}
Finally in variable "days" I got some numbres like -13140000000 or 13176000000
I want some help with this,I tried alot of thing for parse date with no results.