gluu
静的公開メンバ関数 | 静的公開変数類 | 非公開メンバ関数 | 全メンバ一覧
org.gluu.oxtrust.model.scim2.util.DateUtil クラス
org.gluu.oxtrust.model.scim2.util.DateUtil 連携図
Collaboration graph

静的公開メンバ関数

static String ISOToGeneralizedStringDate (String strDate)
 
static String generalizedToISOStringDate (String strDate)
 
static String millisToISOString (long millis)
 

静的公開変数類

static final String GENERALIZED_TIME_FORMAT ="YYYYMMddHHmmss.SSSZ"
 

非公開メンバ関数

 DateUtil ()
 

詳解

Contains helper methods to convert between dates in ISO format and LDAP generalized time syntax.

Examples of ISO-formated dates:

Equivalent dates in generalized time format:

構築子と解体子

◆ DateUtil()

org.gluu.oxtrust.model.scim2.util.DateUtil.DateUtil ( )
inlineprivate
39 {}

関数詳解

◆ generalizedToISOStringDate()

static String org.gluu.oxtrust.model.scim2.util.DateUtil.generalizedToISOStringDate ( String  strDate)
inlinestatic

Converts a string representing a date (in the LDAP generalized time syntax) to an ISO-8601 formatted string date.

引数
strDateA string date in generalized time syntax (see RFC 4517 section 3.3.13)
戻り値
A string representation of a date in ISO format. If the date passed as parameter did not adhere to generalized time syntax, null is returned.
77  {
78 
79  String isoFormatted;
80  try {
81  DateTimeFormatter fmt = DateTimeFormat.forPattern(GENERALIZED_TIME_FORMAT);
82  DateTime dt = fmt.parseDateTime(strDate);
83  isoFormatted = ISODateTimeFormat.dateTime().print(dt);
84  }
85  catch (Exception e){
86  isoFormatted = null;
87  }
88  return isoFormatted;
89 
90  }
static final String GENERALIZED_TIME_FORMAT
Definition: DateUtil.java:37

◆ ISOToGeneralizedStringDate()

static String org.gluu.oxtrust.model.scim2.util.DateUtil.ISOToGeneralizedStringDate ( String  strDate)
inlinestatic

Converts a string representation of a date (expected to follow the pattern of DateTime XML schema data type) to a string representation of a date in LDAP generalized time syntax (see RFC 4517 section 3.3.13).

xsd:dateTime is equivalent to ISO-8601 format, namely, yyyy-MM-dd'T'HH:mm:ss.SSSZZ

引数
strDateA string date in ISO format.
戻り値
A String representing a date in generalized time syntax. If the date passed as parameter did not adhere to xsd:dateTime, the returned value is null
49  {
50 
51  String utcFormatted=null;
52  try {
53  //Check if date passed complies the xsd:dateTime definition
54  Pattern p=Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.*");
55  if (p.matcher(strDate).find()) {
56  //For ISO compliant dates, the new operator suffices to get a DateTime here
57  DateTime dt = new DateTime(strDate);
58  DateTimeFormatter fmt = DateTimeFormat.forPattern(GENERALIZED_TIME_FORMAT);
59  utcFormatted = fmt.withZone(DateTimeZone.UTC).print(dt);
60  //drop UTC timezone info (4 zeroes and sign)
61  utcFormatted = utcFormatted.substring(0, utcFormatted.length() - 5) + "Z";
62  }
63  }
64  catch (Exception e){
65  utcFormatted=null;
66  }
67  return utcFormatted;
68 
69  }
static final String GENERALIZED_TIME_FORMAT
Definition: DateUtil.java:37

◆ millisToISOString()

static String org.gluu.oxtrust.model.scim2.util.DateUtil.millisToISOString ( long  millis)
inlinestatic

Returns a string representation of a date in ISO format based on a number of milliseconds elapsed from "the epoch", namely January 1, 1970, 00:00:00 GMT.

引数
millisNumber of milliseconds
戻り値
An ISO-formatted string date
98  {
99  //Useful for SCIM-client
100  DateTime dt=new DateTime(millis);
101  return ISODateTimeFormat.dateTime().print(dt);
102  }

メンバ詳解

◆ GENERALIZED_TIME_FORMAT

final String org.gluu.oxtrust.model.scim2.util.DateUtil.GENERALIZED_TIME_FORMAT ="YYYYMMddHHmmss.SSSZ"
static

Format used by LDAP generalized time syntax (see RFC 4517 section 3.3.13)


このクラス詳解は次のファイルから抽出されました: