com.google.gwt.i18n.client.TimeZone Java Examples
The following examples show how to use
com.google.gwt.i18n.client.TimeZone.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GanttDateTimeService.java From gantt with Apache License 2.0 | 6 votes |
public String formatDate(Date date, String formatStr, TimeZone timeZone) { /* * Format month and day names separately when locale for the * DateTimeService is not the same as the browser locale */ formatStr = formatMonthNames(date, formatStr); formatStr = formatDayNames(date, formatStr); // Format uses the browser locale DateTimeFormat format = DateTimeFormat.getFormat(formatStr); if (timeZone != null) { return format.format(date, timeZone); } else { return format.format(date, gmt); } }
Example #2
Source File: GanttUtil.java From gantt with Apache License 2.0 | 5 votes |
/** * Returns daylight saving adjustment (in minutes) for normalized date. * Normalized date is zoned date without DST. * * @param normalDate * Date representing target time zone without DST. * @param targetTimeZone * @return Daylight saving adjustment in minutes */ public static native int getDaylightAdjustmentForNormalDate(Long normalDate, TimeZone targetTimeZone) /*-{ if ([email protected]::transitionPoints == null) { return 0; } var timeInHours = normalDate / 1000 / 3600; var index = 0; while (index < [email protected]::transitionPoints.length && timeInHours >= ([email protected]::transitionPoints[index] - ( ((index == 0) ? 0 : [email protected]::adjustments[index - 1]) / 60) )) { ++index; } return (index == 0) ? 0 : [email protected]::adjustments[index - 1]; }-*/;
Example #3
Source File: JsFacade.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
@UsedByApp public void init(JsConfig config) { provider = (JsFileSystemProvider) Storage.getFileSystemRuntime(); String clientName = IdentityUtils.getClientName(); String uniqueId = IdentityUtils.getUniqueId(); ConfigurationBuilder configuration = new ConfigurationBuilder(); configuration.setApiConfiguration(new ApiConfiguration(APP_NAME, APP_ID, APP_KEY, clientName, uniqueId)); configuration.setPhoneBookProvider(new JsPhoneBookProvider()); configuration.setNotificationProvider(new JsNotificationsProvider()); configuration.setCallsProvider(new JsCallsProvider()); // Setting locale String locale = LocaleInfo.getCurrentLocale().getLocaleName(); if (locale.equals("default")) { Log.d(TAG, "Default locale found"); configuration.addPreferredLanguage("en"); } else { Log.d(TAG, "Locale found:" + locale); configuration.addPreferredLanguage(locale.toLowerCase()); } // Setting timezone int offset = new Date().getTimezoneOffset(); String timeZone = TimeZone.createTimeZone(offset).getID(); Log.d(TAG, "TimeZone found:" + timeZone + " for delta " + offset); configuration.setTimeZone(timeZone); // LocaleInfo.getCurrentLocale().getLocaleName() // Is Web application configuration.setPlatformType(PlatformType.WEB); // Device Category // Only Desktop is supported for JS library configuration.setDeviceCategory(DeviceCategory.DESKTOP); // Adding endpoints for (String endpoint : config.getEndpoints()) { configuration.addEndpoint(endpoint); } if (config.getLogHandler() != null) { final JsLogCallback callback = config.getLogHandler(); JsLogProvider.setLogCallback(new JsLogProvider.LogCallback() { @Override public void log(String tag, String level, String message) { callback.log(tag, level, message); } }); } messenger = new JsMessenger(configuration.build()); Log.d(TAG, "JsMessenger created"); }
Example #4
Source File: ServerDateTimeFormat.java From unitime with Apache License 2.0 | 4 votes |
@Override public void onSuccess(ServerTimeZoneResponse result) { sServerTimeZone = TimeZone.createTimeZone(result.toJsonString()); Cookies.setCookie("UniTime:ServerTimeZone", result.toJsonString()); }
Example #5
Source File: ServerDateTimeFormat.java From unitime with Apache License 2.0 | 4 votes |
public static TimeZone getServerTimeZone() { return sServerTimeZone; }
Example #6
Source File: GanttConnector.java From gantt with Apache License 2.0 | 4 votes |
@Override public TimeZone getTimeZone() { return timeZone; }
Example #7
Source File: GanttConnector.java From gantt with Apache License 2.0 | 4 votes |
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); locale = getState().locale; timeZoneId = getState().timeZoneId; if (stateChangeEvent.hasPropertyChanged("locale")) { dateTimeService = null; } if (stateChangeEvent.hasPropertyChanged("timeZoneId")) { if (getState().timeZoneJson != null) { timeZone = TimeZone.createTimeZone(getState().timeZoneJson); } else { timeZone = TimeZone.createTimeZone(0); } } final boolean changeHasInpactToSteps = stateChangeEvent.hasPropertyChanged("resolution") || stateChangeEvent.hasPropertyChanged("startDate") || stateChangeEvent.hasPropertyChanged("endDate"); if (stateChangeEvent.hasPropertyChanged("monthRowVisible") || stateChangeEvent.hasPropertyChanged("yearRowVisible") || stateChangeEvent.hasPropertyChanged("monthFormat") || stateChangeEvent.hasPropertyChanged("yearFormat") || stateChangeEvent.hasPropertyChanged("weekFormat") || stateChangeEvent.hasPropertyChanged("dayFormat") || stateChangeEvent.hasPropertyChanged("hourFormat")) { notifyHeight = !stateChangeEvent.isInitialStateChange(); getWidget().setForceUpdateTimeline(); } if (!notifyHeight && stateChangeEvent.hasPropertyChanged("resolution")) { notifyHeight = !stateChangeEvent.isInitialStateChange(); } if (stateChangeEvent.hasPropertyChanged("movableSteps") || stateChangeEvent.hasPropertyChanged("resizableSteps")) { getWidget().resetListeners(); } if (stateChangeEvent.hasPropertyChanged("readOnly")) { getWidget().setMovableSteps(!getState().readOnly && getState().movableSteps); getWidget().setResizableSteps(!getState().readOnly && getState().resizableSteps); for (StepWidget s : getSteps()) { s.setReadOnly(getState().readOnly); } } if (stateChangeEvent.hasPropertyChanged("verticalScrollDelegateTarget")) { handleVerticalScrollDelegateTargetChange(); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { getWidget().update(getSteps()); if (notifyHeight) { getWidget().notifyHeightChanged(previousHeight); } if (changeHasInpactToSteps) { updateAllStepsPredecessors(); } updateVerticalScrollDelegation(); adjustDelegateTargetHeightLazily(); } }); }
Example #8
Source File: BeanJsonSerializerCreator.java From gwt-jackson with Apache License 2.0 | 4 votes |
private Optional<MethodSpec> generatePropertySerializerParameters( PropertyInfo property, JSerializerType serializerType ) throws UnableToCompleteException { if ( !property.getFormat().isPresent() && !property.getIgnoredProperties().isPresent() && !property.getIgnoreUnknown().isPresent() && !property.getIdentityInfo().isPresent() && !property.getTypeInfo().isPresent() && !property.getInclude().isPresent() && !property.isUnwrapped() ) { // none of the parameter are set so we don't generate the method return Optional.absent(); } JClassType annotatedType = findFirstTypeToApplyPropertyAnnotation( serializerType ); CodeBlock.Builder paramBuilder = CodeBlock.builder() .add( "return new $T()", JsonSerializerParameters.class ) .indent() .indent(); buildCommonPropertyParameters( paramBuilder, property ); if ( property.getFormat().isPresent() ) { JsonFormat format = property.getFormat().get(); if ( !Strings.isNullOrEmpty( format.timezone() ) && !JsonFormat.DEFAULT_TIMEZONE.equals( format.timezone() ) ) { java.util.TimeZone timeZoneJdk = java.util.TimeZone.getTimeZone( format.timezone() ); // in java the offset is in milliseconds from timezone to GMT // in gwt the offset is in minutes from GMT to timezone // so we convert the milliseconds in minutes and invert the sign int timeZoneOffsetGwt = (timeZoneJdk.getRawOffset() / 1000 / 60) * -1; paramBuilder.add( "\n.setTimezone($T.createTimeZone($L))", TimeZone.class, timeZoneOffsetGwt ); } } if ( property.getInclude().isPresent() ) { paramBuilder.add( "\n.setInclude($T.$L)", Include.class, property.getInclude().get().name() ); } if ( property.getIdentityInfo().isPresent() ) { try { Optional<JSerializerType> identitySerializerType = getIdentitySerializerType( property.getIdentityInfo().get() ); paramBuilder.add( "\n.setIdentityInfo($L)", generateIdentifierSerializationInfo( annotatedType, property.getIdentityInfo().get(), identitySerializerType ) ); } catch ( UnsupportedTypeException e ) { logger.log( Type.WARN, "Identity type is not supported. We ignore it." ); } } if ( property.getTypeInfo().isPresent() ) { paramBuilder.add( "\n.setTypeInfo($L)", generateTypeInfo( property.getTypeInfo().get() ) ); } if ( property.isUnwrapped() ) { paramBuilder.add( "\n.setUnwrapped(true)" ); } paramBuilder.add( ";\n" ) .unindent() .unindent(); return Optional.of( MethodSpec.methodBuilder( "newParameters" ) .addModifiers( Modifier.PROTECTED ) .addAnnotation( Override.class ) .returns( JsonSerializerParameters.class ) .addCode( paramBuilder.build() ) .build() ); }
Example #9
Source File: LocaleDataProvider.java From gantt with Apache License 2.0 | 2 votes |
/** * Get currently active Gantt specific time-zone. */ TimeZone getTimeZone();
Example #10
Source File: DateFormat.java From gwt-jackson with Apache License 2.0 | 2 votes |
/** * Format a date using {@link #DATE_FORMAT_STR_ISO8601} and {@link TimeZone} given in parameter * * @param timeZone timezone to use * @param date date to format * @return the formatted date */ public static String format( TimeZone timeZone, Date date ) { return format( DateFormat.DATE_FORMAT_STR_ISO8601, timeZone, date ); }
Example #11
Source File: JsonSerializerParameters.java From gwt-jackson with Apache License 2.0 | 2 votes |
/** * <p>Getter for the field <code>timezone</code>.</p> * * @return a {@link com.google.gwt.i18n.client.TimeZone} object. */ public TimeZone getTimezone() { return timezone; }
Example #12
Source File: JsonSerializerParameters.java From gwt-jackson with Apache License 2.0 | 2 votes |
/** * <p>Setter for the field <code>timezone</code>.</p> * * @param timezone a {@link com.google.gwt.i18n.client.TimeZone} object. * @return a {@link com.github.nmorel.gwtjackson.client.JsonSerializerParameters} object. */ public JsonSerializerParameters setTimezone( TimeZone timezone ) { this.timezone = timezone; return this; }