protected TimeZone getTimeZoneFromArgs(String[] args, int pos) { if (pos < args.length) { if ("USER_TIMEZONE".equalsIgnoreCase(args[pos].trim())) { UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME); if (userSessionSource.checkCurrentUserSession()) { UserSession userSession = userSessionSource.getUserSession(); return userSession.getTimeZone(); } } } return null; } }
if (userSessionSource.checkCurrentUserSession()) { UserSession userSession = userSessionSource.getUserSession(); if (userSession.getTimeZone() != null) { df.setTimeZone(userSession.getTimeZone());
/** * Format Date (date and time) using {@code dateTimeFormat} string specified in the main message pack. * <p>Takes into account time zone if it is set for the current user session.</p> * @return string representation or empty string if the value is null */ public String formatDateTime(@Nullable Date value) { TimeZone timeZone = uss.getUserSession().getTimeZone(); Datatype<Date> datatype = datatypeRegistry.getNN(Date.class); if (datatype instanceof DateTimeDatatype) { return ((DateTimeDatatype) datatype).format(value, uss.getLocale(), timeZone); } return datatype.format(value, uss.getLocale()); }
/** * Parse Date (date and time) using {@code dateTimeFormat} string specified in the main message pack. * <p>Takes into account time zone if it is set for the current user session.</p> * @return Date value or null if a blank string is provided */ @Nullable public Date parseDateTime(String str) throws ParseException { TimeZone timeZone = uss.getUserSession().getTimeZone(); Datatype<Date> datatype = datatypeRegistry.getNN(Date.class); if (datatype instanceof DateTimeDatatype) { return ((DateTimeDatatype) datatype).parse(str, uss.getLocale(), timeZone); } return datatype.parse(str, uss.getLocale()); }
@Inject public void setBeanLocator(BeanLocator beanLocator) { super.setBeanLocator(beanLocator); UserSessionSource uss = beanLocator.get(UserSessionSource.NAME); TimeZone timeZone = uss.getUserSession().getTimeZone(); TimeZones timeZones = beanLocator.get(TimeZones.NAME); component.setValue(timeZones.getDisplayNameShort(timeZone)); if (timeZone == null) { // hidden by default if timeZone is null setVisible(false); } }
ListEditor.ItemType itemType = dateOnly ? ListEditor.ItemType.DATE : ListEditor.ItemType.DATETIME; listEditor.setItemType(itemType); if (userSession.getTimeZone() != null && supportTimezones) { listEditor.setTimeZone(userSession.getTimeZone()); if (userSession.getTimeZone() != null && supportTimezones) { dateField.setTimeZone(userSession.getTimeZone());
public void setupZoneId(DateField component, EntityValueSource valueSource) { if (component.getZoneId() == null) { MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty(); Class javaType = metaProperty.getRange().asDatatype().getJavaClass(); if (dateTimeTransformations.isDateTypeSupportsTimeZones(javaType)) { Boolean ignoreUserTimeZone = metadataTools.getMetaAnnotationValue(metaProperty, IgnoreUserTimeZone.class); if (!Boolean.TRUE.equals(ignoreUserTimeZone)) { TimeZone timeZone = userSessionSource.getUserSession().getTimeZone(); component.setTimeZone(timeZone); } } } }
if (!Boolean.TRUE.equals(ignoreUserTimeZone)) { return ((TimeZoneAwareDatatype) datatype).format(value, userSessionSource.getLocale(), userSessionSource.getUserSession().getTimeZone());
@Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { SecurityContext securityContext = AppContext.getSecurityContext(); CubaRemoteInvocation remoteInvocation = new CubaRemoteInvocation(methodInvocation, securityContext == null ? null : securityContext.getSessionId()); if (securityContext != null) { UserSession session = securityContext.getSession(); if (session instanceof ClientBasedSession && ((ClientBasedSession) session).hasRequestScopedInfo()) { remoteInvocation.setLocale(session.getLocale() != null ? session.getLocale().toLanguageTag() : null); remoteInvocation.setTimeZone(session.getTimeZone()); remoteInvocation.setAddress(session.getAddress()); remoteInvocation.setClientInfo(session.getClientInfo()); } } return remoteInvocation; } }
invocation.setTimeZone(session.getTimeZone()); invocation.setAddress(session.getAddress()); invocation.setClientInfo(session.getClientInfo());
invocation.setTimeZone(session.getTimeZone()); invocation.setAddress(session.getAddress()); invocation.setClientInfo(session.getClientInfo());
Class javaClass = null; boolean supportTimezones = false; TimeZone timeZone = userSessionSource.getUserSession().getTimeZone(); if (metaPropertyPath != null) { MetaProperty metaProperty = metaPropertyPath.getMetaProperty();
TimeZone userTimeZone = userSessionSource.getUserSession().getTimeZone(); if (userTimeZone != null) { setTimeZone(userTimeZone);
if (Boolean.TRUE.equals(e.getValue())) { UserSession userSession = userSessionSource.getUserSession(); if (userSession.getTimeZone() != null) { dateField.setTimeZone(userSession.getTimeZone());