[ 
https://issues.apache.org/jira/browse/DIRAPI-284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15448325#comment-15448325
 ] 

TvT edited comment on DIRAPI-284 at 8/30/16 7:31 AM:
-----------------------------------------------------

Yeah that convenience method would be nice to have since many people have that 
problem...
A rudimentary method could look like this:

{code:borderStyle=solid}
private Date convertMicrosoftFileTimeDate(String adDate){
    long offset = 11644473600000L;  // offset milliseconds from Jan 1, 1601 to 
Jan 1, 1970
    // convert 100-nanosecond intervals to milliseconds
    long javaTime = (Long.parseLong(adDate) / 10000 - offset);
        
    return new Date(javaTime);
}
{code}

One last remark: I think the INFINITE (0x7FFFFFFFFFFFFFFF) ... is only used for 
the 18 digit timestamp and not for the ISO-8601 timestamp. However can't hurt 
to use it for both...



was (Author: teewetee):
Yeah that convenience method would be nice to have since many people have that 
problem...
A rudimentary method could look like this:

private Date convertMicrosoftFileTimeDate(String adDate){
        long offset = 11644473600000L;  // offset milliseconds from Jan 1, 1601 
to Jan 1, 1970
        // convert 100-nanosecond intervals to milliseconds
        long javaTime = (Long.parseLong(adDate) / 10000 - offset);
                
        return new Date(javaTime);
}
One last remark: I think the INFINITE (0x7FFFFFFFFFFFFFFF) ... is only used for 
the 18 digit timestamp and not for the ISO-8601 timestamp. However can't hurt 
to use it for both...


> DateUtils throws an exception for certain timestamps
> ----------------------------------------------------
>
>                 Key: DIRAPI-284
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-284
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC1
>         Environment: All
>            Reporter: TvT
>             Fix For: 1.0.0-RC2
>
>
> The DateUtils class can't handle certain timestamps.
> The following code
> _DateUtils.getDate("9223372036854775807");_
> throws an "java.lang.RuntimeException: java.text.ParseException: ERR_04363 
> Invalid Time too short, expected field 'fraction of second' or 'timezone'."
> The value in [microsofts active directory 
> |https://msdn.microsoft.com/en-us/library/ms675098%28v=vs.85%29.aspx]indicates
>  that e.g. an account never expires...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to