Date Filter in java -


this question has answer here:

i need filter date "from date" "to date" using "current date" filter.

here code use in java application:

string = "19/05/1991"; string cmp = "23/05/1991"; string = "23/12/2015";  if (from.compareto(cmp) <= 0 && to.compareto(cmp) >= 0) {     system.out.println("date lies between , date"); } 

is code correct?

you should this:

string = "19/05/1991"; string cmp = "23/05/1991"; string = "23/12/2015";  dateformat format = new simpledateformat("dd/mm/yyyy"); date date1 = format.parse(from); date date2 = format.parse(cmp); date date3 = format.parse(to);  if(date1.before(date2) && date3.after(date2)) {    system.out.println("date lies between , date"); } 

see date#after , date#before


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -