gluu
公開メンバ関数 | 全メンバ一覧
org.gluu.credmanager.ui.CustomDateConverter クラス
org.gluu.credmanager.ui.CustomDateConverter の継承関係図
Inheritance graph
org.gluu.credmanager.ui.CustomDateConverter 連携図
Collaboration graph

公開メンバ関数

Object coerceToUi (Object val, Component comp, BindContext ctx)
 
Object coerceToBean (Object val, Component comp, BindContext ctx)
 

詳解

This class is a ZK converter employed to display dates appropriately according to user location. It uses the time offset with respect to UTC time and a formatting pattern supplied to show dates

著者
jgomer

関数詳解

◆ coerceToBean()

Object org.gluu.credmanager.ui.CustomDateConverter.coerceToBean ( Object  val,
Component  comp,
BindContext  ctx 
)
inline
65  {
66  return null;
67  }

◆ coerceToUi()

Object org.gluu.credmanager.ui.CustomDateConverter.coerceToUi ( Object  val,
Component  comp,
BindContext  ctx 
)
inline

This method is called when conversion is taking placing in .zul templates

引数
valAn object representing a date, namely a java.util.Date or a long value (milliseconds from the epoch)
compThe UI component associated to this converstion
ctxBinding context. It holds the conversion arguments: "format" and "offset" are used here
戻り値
A string with the date properly formatted or null if val parameter is not a valid date
36  {
37 
38  long timeStamp = (val instanceof Date) ? ((Date) val).getTime() : (long) val;
39  if (timeStamp > 0) {
40 
41  String format = (String) ctx.getConverterArg("format");
42  Object offset = ctx.getConverterArg("offset");
43  ZoneId zid;
44 
45  if (offset != null && ZoneId.class.isAssignableFrom(offset.getClass())) {
46  zid = (ZoneId) offset;
47  } else { //This covers the weird case in which there is no offset set
48  zid = ZoneOffset.UTC;
49  if (format.contains("hh") || format.contains("HH") || format.contains("mm")) {
50  format += " '(GMT)'";
51  }
52  }
53  Instant instant = Instant.ofEpochMilli(timeStamp);
54  OffsetDateTime odt = OffsetDateTime.ofInstant(instant, zid);
55 
56  ServletRequest request = (ServletRequest) Executions.getCurrent().getNativeRequest();
57  Locale locale = request.getLocale() == null ? Locale.getDefault() : request.getLocale();
58  return odt.format(DateTimeFormatter.ofPattern(format, locale));
59  } else {
60  return null;
61  }
62 
63  }

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