android - How To See If One Date Is Newer Than Another -
hello think have simple question i'm having trouble figuring out.
i got date , time in android using code
string currentdatetimestring = dateformat.getdateinstance().format(new date());
it gave me value
apr 21, 2016 9:30:16 pm
how compare using dates value if want see if
apr 21, 2016 9:30:16 pm
is newer or older
apr 21, 2016 9:35:16 pm
how check thanks
attempt one
i tried
dateformat format = new simpledateformat("mm-dd-yyyy", locale.english); date filedate = format.parse(date1); dateformat format2 = new simpledateformat("mm-dd-yyyy", locale.english); date metadate = format.parse(date2);
this value date 1 , 2 being
apr 21, 2016 9:35:16 pm
but threw parse exception. must use value above need doesn't break code when tries parse date
the easiest way use date.before(), rather comparing strings. in fact easier convert string date use strings.
Comments
Post a Comment