当前位置: 首页>>代码示例>>Java>>正文


Java TimeZone类代码示例

本文整理汇总了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);

}
 
开发者ID:waynedyck,项目名称:mgwt-traffic-flow,代码行数:27,代码来源:ParserUtils.java

示例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);
    }
}
 
开发者ID:tltv,项目名称:gantt,代码行数:18,代码来源:GanttDateTimeService.java

示例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];
}-*/;
 
开发者ID:tltv,项目名称:gantt,代码行数:24,代码来源:GanttUtil.java

示例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);

}
 
开发者ID:WSDOT,项目名称:wsdot-mobile-app,代码行数:20,代码来源:ParserUtils.java

示例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);
	}
 
开发者ID:ls1intum,项目名称:MIBO-IDE,代码行数:36,代码来源:WCConsoleArea.java

示例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;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:8,代码来源:EditTargetDiv.java

示例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());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:6,代码来源:ServerDateTimeFormat.java

示例8: getServerTimeZone

import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public static TimeZone getServerTimeZone() {
	return sServerTimeZone;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:4,代码来源:ServerDateTimeFormat.java

示例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));
}
 
开发者ID:baldram,项目名称:tristar-eye,代码行数:6,代码来源:ResourcesRetriever.java

示例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");
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:59,代码来源:JsFacade.java

示例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);
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:6,代码来源:JDKDateFormatter.java

示例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);
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:5,代码来源:GWTDateFormatter.java

示例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
}
 
开发者ID:codeaudit,项目名称:gwt-chronoscope,代码行数:5,代码来源:JsonMipper.java

示例14: getDepartureTimezone

import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public TimeZone getDepartureTimezone() {
	return departureTimezone;
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:4,代码来源:ItineraryTransitLegBean.java

示例15: setDepartureTimezone

import com.google.gwt.i18n.client.TimeZone; //导入依赖的package包/类
public void setDepartureTimezone(TimeZone departureTimezone) {
	this.departureTimezone = departureTimezone;
}
 
开发者ID:mecatran,项目名称:OpenTripPlanner-client-gwt,代码行数:4,代码来源:ItineraryTransitLegBean.java


注:本文中的com.google.gwt.i18n.client.TimeZone类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。