Convert LDAP attribute generalizedTimeSyntax to Date


/ Published in: Java
Save to your folder(s)

Use UnboundID LDAP SDK entry.getAttributeValueAsDate()


Copy this code and paste it in your HTML
  1. /**
  2.  * If the entry has the attribute {@code attributeType},
  3.  * converts the attribute value specified by {@code attributeType}
  4.  * to a {@code Date} and returns the date; otherwise returns {@code null}.
  5.  *
  6.  * @param attributeType
  7.  * The attribute type whose value will be converted
  8.  * to a {@code Date}; must not be {@code null}.
  9.  *
  10.  * @return attributeType's value as a {@code Date}.
  11.  */
  12. private Date getTime(String attributeType) {
  13. return entry.hasAttribute(attributeType)
  14. ? entry.getAttributeValueAsDate(attributeType)
  15. : null;
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.