You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by pkrishna <pr...@ge.com> on 2008/11/13 01:22:54 UTC

Comparing by time

I am trying to do a search based on Modified time. What I am observing is the
time format in the node is different from when I am using a
SimpleDateFormat; For example, in the node the lastModified time is saved as
2008-11-12T16:46:57.089-07:00. I used SimpleDateFormat using the pattern
yyyy-MM-dd'T'HH:mm:ss.SSSZ which seems to be the closest to the format of
the time in the node. I observed for the same date, the call
SimpleDateFormat.format produces a string which ends with -700 which is
slightly different from -07:00. So my question is how I incorporate into a
query that does an exact match on the date. Is this even possible?
-- 
View this message in context: http://www.nabble.com/Comparing-by-time-tp20472546p20472546.html
Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.


Re: Comparing by time

Posted by Paco Avila <pa...@git.es>.
Use "org.apache.jackrabbit.util.ISO8601" for date format.

On Thu, Nov 13, 2008 at 2:09 PM, Jukka Zitting <ju...@gmail.com>wrote:

> Hi,
>
> On Thu, Nov 13, 2008 at 1:22 AM, pkrishna <pr...@ge.com>
> wrote:
> > I am trying to do a search based on Modified time. What I am observing is
> the
> > time format in the node is different from when I am using a
> > SimpleDateFormat; For example, in the node the lastModified time is saved
> as
> > 2008-11-12T16:46:57.089-07:00. I used SimpleDateFormat using the pattern
> > yyyy-MM-dd'T'HH:mm:ss.SSSZ which seems to be the closest to the format of
> > the time in the node. I observed for the same date, the call
> > SimpleDateFormat.format produces a string which ends with -700 which is
> > slightly different from -07:00. So my question is how I incorporate into
> a
> > query that does an exact match on the date. Is this even possible?
>
> The easiest way to format dates using the exact format specified in
> JSR-170 is to use the following code:
>
>    Calendar date = ...;
>    session.getValueFactory().getValue(date).getString();
>
> Similarly, you can parse JSR-170 date values like this:
>
>    String date = ...;
>    session.getValueFactory().getValue(date).getDate();
>
> BR,
>
> Jukka Zitting
>



-- 
Paco Avila
GIT Consultors
tel: +34 971 498310
fax: +34 971496189
e-mail: pavila@git.es
http://www.git.es

Re: Comparing by time

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Thu, Nov 13, 2008 at 1:22 AM, pkrishna <pr...@ge.com> wrote:
> I am trying to do a search based on Modified time. What I am observing is the
> time format in the node is different from when I am using a
> SimpleDateFormat; For example, in the node the lastModified time is saved as
> 2008-11-12T16:46:57.089-07:00. I used SimpleDateFormat using the pattern
> yyyy-MM-dd'T'HH:mm:ss.SSSZ which seems to be the closest to the format of
> the time in the node. I observed for the same date, the call
> SimpleDateFormat.format produces a string which ends with -700 which is
> slightly different from -07:00. So my question is how I incorporate into a
> query that does an exact match on the date. Is this even possible?

The easiest way to format dates using the exact format specified in
JSR-170 is to use the following code:

    Calendar date = ...;
    session.getValueFactory().getValue(date).getString();

Similarly, you can parse JSR-170 date values like this:

    String date = ...;
    session.getValueFactory().getValue(date).getDate();

BR,

Jukka Zitting