Friday, 5 December 2014

Date Comparison (Which date is greater)

String FromstrThatDay = order_search_popupwindow_From.getText().toString().trim().replaceAll("-", "/");
SimpleDateFormat Fromformatter = new SimpleDateFormat("dd/MM/yyyy");
Date FromdateOrig = null;
try 
{
FromdateOrig = Fromformatter.parse(FromstrThatDay);//catch exception
catch (Exception e) 
{
// TODO Auto-generated catch block
e.printStackTrace();

Calendar FromthatDay = Calendar.getInstance();
FromthatDay.setTime(FromdateOrig);
String TostrThatDay = order_search_popupwindow_To.getText().toString().trim().replaceAll("-", "/");
SimpleDateFormat Toformatter = new SimpleDateFormat("dd/MM/yyyy");
Date Tod = null;
try
{
Tod = Toformatter.parse(TostrThatDay);//catch exception
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();

Calendar TothatDay = Calendar.getInstance();
TothatDay.setTime(Tod);
long from_DateMili,to_DateMili,TotaleMili;
from_DateMili = FromthatDay.getTimeInMillis();
to_DateMili  = TothatDay.getTimeInMillis();
TotaleMili = to_DateMili-from_DateMili;

No comments:

Post a Comment