You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Kiran Ayyagari <ay...@gmail.com> on 2008/11/08 20:39:24 UTC

[SHARED-LDAP] new methods in DateUtils class

hi guys,

    I want to add two new methods to DateUtils class for getting the generalized
    time string in a convenient way when providing a Date object or time as a
    long value

    waiting for your view(s) before committing it

    they look like below mentioned code

     /**
      *
      * @see #getGeneralizedTime()
      *
      * @param date the date to be converted to generalized time string
      * @return given date in the generalized time string format
      */
     public static String getGeneralizedTime( Date date )
     {
         synchronized ( dateFormat )
         {
             return dateFormat.format( date );
         }
     }


     /**
      *
      * @see #getGeneralizedTime()
      *
      * @param time the time value to be converted to generalized time string
      * @return given time in generalized time string format
      */
     public static String getGeneralizedTime( long time )
     {
         return getGeneralizedTime( new Date( time ) );
     }

-- 
Kiran Ayyagari

Re: [SHARED-LDAP] new methods in DateUtils class

Posted by Emmanuel Lecharny <el...@gmail.com>.
Kiran Ayyagari wrote:
> thanks Seelmann for the info, however the quartz LDAP store on which am
> currently working will be part of the server so using DateUtils will 
> do the
> work.
>
> I have another question, the clients will change the scheduled 
> execution time for a quartz job/trigger, in this case
>
> 1) should we force the user to specify time in GMT? or
> 2) would it be better if we take the client's timezone along with time 
> and doing
>    the actual conversion to GMT
The rule should be that the user must work with his TZ, and the server 
should work with GMT, I think. Then, it's just a matter of converting 
date back and forth.

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: [SHARED-LDAP] new methods in DateUtils class

Posted by Kiran Ayyagari <ay...@gmail.com>.
thanks Seelmann for the info, however the quartz LDAP store on which am
currently working will be part of the server so using DateUtils will do the
work.

I have another question, the clients will change the scheduled execution time 
for a quartz job/trigger, in this case

1) should we force the user to specify time in GMT? or
2) would it be better if we take the client's timezone along with time and doing
    the actual conversion to GMT


   P.S :- 1 is putting pain on the user side which I think we all try to avoid :)

wdot?

Kiran Ayyagari

Stefan Seelmann wrote:
> Hi Kiran,
> 
> sure, you could add these convenient methods.
> 
> However be aware of the missing time zone information. Date objects and
> timestamps don't contain any time zone information while the generalized
> time does. The DateUtils class always assumes 'Z' time zone.
> 
> For that reason I created a GeneralizedTime class that is based on
> java.util.Calendar.
> 
> Kind Regards,
> Stefan Seelmann
> 
> 
> 
> Kiran Ayyagari wrote:
>> hi guys,
>>
>>    I want to add two new methods to DateUtils class for getting the
>> generalized
>>    time string in a convenient way when providing a Date object or time
>> as a
>>    long value
>>
>>    waiting for your view(s) before committing it
>>
>>    they look like below mentioned code
>>
>>     /**
>>      *
>>      * @see #getGeneralizedTime()
>>      *
>>      * @param date the date to be converted to generalized time string
>>      * @return given date in the generalized time string format
>>      */
>>     public static String getGeneralizedTime( Date date )
>>     {
>>         synchronized ( dateFormat )
>>         {
>>             return dateFormat.format( date );
>>         }
>>     }
>>
>>
>>     /**
>>      *
>>      * @see #getGeneralizedTime()
>>      *
>>      * @param time the time value to be converted to generalized time
>> string
>>      * @return given time in generalized time string format
>>      */
>>     public static String getGeneralizedTime( long time )
>>     {
>>         return getGeneralizedTime( new Date( time ) );
>>     }
>>
> 
> 

Re: [SHARED-LDAP] new methods in DateUtils class

Posted by Stefan Seelmann <se...@apache.org>.
Hi Kiran,

sure, you could add these convenient methods.

However be aware of the missing time zone information. Date objects and
timestamps don't contain any time zone information while the generalized
time does. The DateUtils class always assumes 'Z' time zone.

For that reason I created a GeneralizedTime class that is based on
java.util.Calendar.

Kind Regards,
Stefan Seelmann



Kiran Ayyagari wrote:
> hi guys,
> 
>    I want to add two new methods to DateUtils class for getting the
> generalized
>    time string in a convenient way when providing a Date object or time
> as a
>    long value
> 
>    waiting for your view(s) before committing it
> 
>    they look like below mentioned code
> 
>     /**
>      *
>      * @see #getGeneralizedTime()
>      *
>      * @param date the date to be converted to generalized time string
>      * @return given date in the generalized time string format
>      */
>     public static String getGeneralizedTime( Date date )
>     {
>         synchronized ( dateFormat )
>         {
>             return dateFormat.format( date );
>         }
>     }
> 
> 
>     /**
>      *
>      * @see #getGeneralizedTime()
>      *
>      * @param time the time value to be converted to generalized time
> string
>      * @return given time in generalized time string format
>      */
>     public static String getGeneralizedTime( long time )
>     {
>         return getGeneralizedTime( new Date( time ) );
>     }
> 


Re: [SHARED-LDAP] new methods in DateUtils class

Posted by Emmanuel Lecharny <el...@gmail.com>.
Kiran Ayyagari wrote:
> hi guys,
Hi,
>
>    I want to add two new methods to DateUtils class for getting the 
> generalized
>    time string in a convenient way when providing a Date object or 
> time as a
>    long value

>
>    waiting for your view(s) before committing it
Just go for it. In any case, I don't see how it can harms anyone :)

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org