Package org.ldaptive.transcode
Class GeneralizedTimeValueTranscoder
- java.lang.Object
-
- org.ldaptive.transcode.AbstractStringValueTranscoder<ZonedDateTime>
-
- org.ldaptive.transcode.GeneralizedTimeValueTranscoder
-
- All Implemented Interfaces:
ValueTranscoder<ZonedDateTime>
public class GeneralizedTimeValueTranscoder extends AbstractStringValueTranscoder<ZonedDateTime>
Decodes and encodes a generalized time for use in an ldap attribute value. See http://tools.ietf.org/html/rfc4517#section-3.3.13
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GeneralizedTimeValueTranscoder.FractionalPart
Describes the fractional part of a generalized time string.
-
Field Summary
Fields Modifier and Type Field Description private static DateTimeFormatter
DATE_FORMAT
Date format.private static String
DAY_PATTERN
Pattern for capturing the day in generalized time.private static String
FRACTION_PATTERN
Pattern for capturing optional fraction in generalized time.private static String
HOUR_PATTERN
Pattern for capturing hours in generalized time.private static String
MIN_PATTERN
Pattern for capturing optional minutes in generalized time.private static String
MONTH_PATTERN
Pattern for capturing the month in generalized time.private static String
SECOND_PATTERN
Pattern for capturing optional seconds in generalized time.private static Pattern
TIME_REGEX
Generalized time format regular expression.private static String
TIMEZONE_PATTERN
Pattern for capturing timezone in generalized time.private static String
YEAR_PATTERN
Pattern for capturing the year in generalized time.
-
Constructor Summary
Constructors Constructor Description GeneralizedTimeValueTranscoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZonedDateTime
decodeStringValue(String value)
Decodes the supplied ldap attribute value into a custom type.String
encodeStringValue(ZonedDateTime value)
Encodes the supplied value into an ldap attribute value.Class<ZonedDateTime>
getType()
Returns the type produced by this value transcoder.protected ZonedDateTime
parseGeneralizedTime(String value)
Parses the supplied value and returns a date time.-
Methods inherited from class org.ldaptive.transcode.AbstractStringValueTranscoder
decodeBinaryValue, encodeBinaryValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ldaptive.transcode.ValueTranscoder
decoder, encoder
-
-
-
-
Field Detail
-
YEAR_PATTERN
private static final String YEAR_PATTERN
Pattern for capturing the year in generalized time.- See Also:
- Constant Field Values
-
MONTH_PATTERN
private static final String MONTH_PATTERN
Pattern for capturing the month in generalized time.- See Also:
- Constant Field Values
-
DAY_PATTERN
private static final String DAY_PATTERN
Pattern for capturing the day in generalized time.- See Also:
- Constant Field Values
-
HOUR_PATTERN
private static final String HOUR_PATTERN
Pattern for capturing hours in generalized time.- See Also:
- Constant Field Values
-
MIN_PATTERN
private static final String MIN_PATTERN
Pattern for capturing optional minutes in generalized time.- See Also:
- Constant Field Values
-
SECOND_PATTERN
private static final String SECOND_PATTERN
Pattern for capturing optional seconds in generalized time.- See Also:
- Constant Field Values
-
FRACTION_PATTERN
private static final String FRACTION_PATTERN
Pattern for capturing optional fraction in generalized time.- See Also:
- Constant Field Values
-
TIMEZONE_PATTERN
private static final String TIMEZONE_PATTERN
Pattern for capturing timezone in generalized time.- See Also:
- Constant Field Values
-
TIME_REGEX
private static final Pattern TIME_REGEX
Generalized time format regular expression.
-
DATE_FORMAT
private static final DateTimeFormatter DATE_FORMAT
Date format.
-
-
Method Detail
-
decodeStringValue
public ZonedDateTime decodeStringValue(String value)
Description copied from interface:ValueTranscoder
Decodes the supplied ldap attribute value into a custom type.- Parameters:
value
- to decode- Returns:
- decoded value
-
encodeStringValue
public String encodeStringValue(ZonedDateTime value)
Description copied from interface:ValueTranscoder
Encodes the supplied value into an ldap attribute value.- Parameters:
value
- to encode- Returns:
- encoded value
-
getType
public Class<ZonedDateTime> getType()
Description copied from interface:ValueTranscoder
Returns the type produced by this value transcoder.- Returns:
- type produced by this value transcoder
-
parseGeneralizedTime
protected ZonedDateTime parseGeneralizedTime(String value) throws ParseException
Parses the supplied value and returns a date time.- Parameters:
value
- of generalized time to parse- Returns:
- date time initialized to the correct time
- Throws:
ParseException
- if the value does not contain correct generalized time syntax
-
-