• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How can I compare adate, that is between two exist date feilds?.

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I compare adate, that is between two exist date feilds?
Like 02/03/2006 is in between like two existing 01/03/2006 and 03/03/2006.
If any one know plz give that code.
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.util.*;

public class DateCheck{
public static void main(String args[]){

Calendar stDateRange = Calendar.getInstance();
Calendar endDateRange = Calendar.getInstance();
Calendar btwDateRange = Calendar.getInstance();

stDateRange.set(2006,3,1);
endDateRange.set(2006,3,3);
btwDateRange.set(2006,3,2);

Date stDate = stDateRange.getTime();
Date endDate = endDateRange.getTime();
Date btwDate = btwDateRange.getTime();

if(btwDate.after(stDate) && btwDate.before(endDate)){
System.out.println("Date is in the range ");
}else{
System.out.println("Date is not in the range");
}
}
}
 
Kondal reddy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanq Arun!
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic