本文整理汇总了Java中com.google.gwt.i18n.client.TimeZone类的典型用法代码示例。如果您正苦于以下问题:Java TimeZone类的具体用法?Java TimeZone怎么用?Java TimeZone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeZone类属于com.google.gwt.i18n.client包,在下文中一共展示了TimeZone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: relativeTime
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
/**
*
* @param createdAt
* @param datePattern
* @param isUTC
* @return
*/
public static String relativeTime(String createdAt, String datePattern, boolean isUTC) {
DateTimeFormat parseDateFormat = DateTimeFormat.getFormat(datePattern);
Date parseDate;
try {
if (isUTC) {
parseDate = parseDateFormat.parse(parseDateFormat.format(
parseDateFormat.parse(createdAt),
TimeZone.createTimeZone(0)));
} else {
parseDate = parseDateFormat.parse(createdAt);
}
} catch (IllegalArgumentException e) {
return "Unavailable";
}
return getRelative(parseDate);
}
示例2: formatDate
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
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);
}
}
示例3: getDaylightAdjustmentForNormalDate
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
/**
* 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];
}-*/;
示例4: relativeTime
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public static String relativeTime(String createdAt, String datePattern, boolean isUTC) {
DateTimeFormat parseDateFormat = DateTimeFormat.getFormat(datePattern);
Date parseDate;
try {
if (isUTC) {
parseDate = parseDateFormat.parse(parseDateFormat.format(
parseDateFormat.parse(createdAt),
TimeZone.createTimeZone(0)));
} else {
parseDate = parseDateFormat.parse(createdAt);
}
} catch (IllegalArgumentException e) {
return "Unavailable";
}
return getRelative(parseDate);
}
示例5: addMessage
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public void addMessage(ConsoleLogType code, String content) {
Date date = new Date();
DateTimeFormat dtf = DateTimeFormat.getFormat("HH:mm:ss:SS");
String output = "";
output += "<span style=\"color:grey\">"
+ dtf.format(date, TimeZone.createTimeZone(this.getClientOffsetTimeZone())) + "</span> ";
switch (code) {
case ERROR:
output += "<span style=\"color:red\">ERROR</span> ";
break;
case SUCCESS:
output += "<span style=\"color:green\">SUCCESS</span> ";
break;
case INFO:
output += "<span style=\"color:grey\">INFO</span> ";
break;
case WARNING:
output += "<span style=\"color:orange\">WARNING</span> ";
break;
case ACTION:
output += "<span style=\"color: #3F51B5;\">ACTION</span> ";
default:
break;
}
output += content;
Element div = DOM.createElement("div");
div.setInnerHTML(output);
this.JSNI_appendChild(this.element, div);
this.JSNI_updatePosition(this.element);
}
示例6: generateRandomID
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
private String generateRandomID() {
Date date = new Date();
DateTimeFormat dtf = DateTimeFormat.getFormat("yyyyMMddHHmmss");
String randomID = "id-" + dtf.format(date,
TimeZone.createTimeZone(0));
return randomID;
}
示例7: onSuccess
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
@Override
public void onSuccess(ServerTimeZoneResponse result) {
sServerTimeZone = TimeZone.createTimeZone(result.toJsonString());
Cookies.setCookie("UniTime:ServerTimeZone", result.toJsonString());
}
示例8: getServerTimeZone
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public static TimeZone getServerTimeZone() {
return sServerTimeZone;
}
示例9: getTimeStamp
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
private String getTimeStamp() {
Date date = new Date();
DateTimeFormat dtf = DateTimeFormat.getFormat(TIMESTAMP_FORMAT);
return dtf.format(date, TimeZone.createTimeZone(0));
}
示例10: init
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
@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");
}
示例11: format
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public String format(double timestamp, TimeZone timezone) {
d.setTime((long)timestamp);
return fmt.format(d); //FIXME
// FIXME return fmt.format(new Date((long) timestamp), timeZoneOffset);
}
示例12: format
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public String format(double timestamp, TimeZone timeZone) {
d.setTime((long)timestamp);
return fmt.format(d, timeZone);
}
示例13: format
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public String format(double timestamp, TimeZone timezone) {
d.setTime((long) timestamp);
return fmt.format(d); // FIXME: TZ
}
示例14: getDepartureTimezone
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public TimeZone getDepartureTimezone() {
return departureTimezone;
}
示例15: setDepartureTimezone
import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public void setDepartureTimezone(TimeZone departureTimezone) {
this.departureTimezone = departureTimezone;
}