hello i' trying to take out data from start time and end time from my database record..any idea how to solve it
for example:

2012-09-08 12:09:33 roadA
2012-09-08 10:49:09 roadA
2012-09-08 10:39:27 roadC
2012-09-08 09:09:33 roadA

if i select 10:39:27 to 12:09:33, then only 3 data will be display...

will youe please ealborate some more,so i can understand your problem properly.

Thanks

I think you are trying to validate of the fetched date is between the given start and end dates. Here is a piece of sample code. Hope you can use it according to your requirement.

    public void checkDates() {
        String startDate = "2012-09-08";
        String endDate = "2012-09-08";
        String startTime = "10:39:27";
        String endTime = "12:09:33";

        String fetchedDate = "2012-09-08 10:49:09";

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
            Date startDt = df.parse(startDate + " " + startTime);
            Date endDt = df.parse(endDate + " " + endTime);
            Date fetchedDt = df.parse(fetchedDate);
            System.out.println("Start : " + startDt + "End : " + endDt + "Fetched : " + fetchedDt);
            if(startDt.before(fetchedDt)&&endDt.after(fetchedDt) ){
                System.out.println("Date " + fetchedDate + " is in between the time limits.");
            }

        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.