Hello what I am trying to do is compare a date
I have in specific format(2020-02-27T15:00:43+0000 format) and today's date.
Just the date not the time.
String saleDate=2020-02-27T15:00:43+0000;
public static int validateCustomer(int idCustomer, double saleBalance, double totalSaleValue, String saleDate){
Config config= new Config().getConfig();
ModuleRoute moduleRoute = new ModuleRoute().getModulesRoute(config.idRoute);
double limit = (double) moduleRoute.allowPercentage;
double paid =totalSaleValue-saleBalance;
Date saleDateFormatD = null;
Date dateToday = new Date();
SimpleDateFormat saleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
try {
saleDateFormatD = saleDateFormat.parse(saleDate);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
SimpleDateFormat justDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String formatSaleDateTime = justDateFormat.format(saleDateFormatD);
String todayDate= justDateFormat.format(dateToday);
if (formatSaleDateTime.equals(todayDate)){
return 0;
}else if ((paid)>(limit)*totalSaleValue){
return 1;
}else
return 2;
//if customer can, return true
}
In this case, it will be check if dt
and date1
are the same.
date
is a string in that format.
Any help or suggestions would be great. thanks