Are you trying to do this in XPath? Have you tried hours-from-dateTime (documentation here? If so, where did you run into problems with that? Just trying to understand more what you need to accomplish and what you've tried.
You have to itterate over all the objects. You should do the custom retrieve with limits and offset so you handle let's say 100 objects at a time. When you iterate over the objects you can then check the time of the attribute ( see the documentation here to see how to get the hour as integer: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html If the time is wrong adjust it otherwise continue with the next iteration. Hope this helps,