Example usage for com.google.gwt.i18n.shared DateTimeFormat format

List of usage examples for com.google.gwt.i18n.shared DateTimeFormat format

Introduction

In this page you can find the example usage for com.google.gwt.i18n.shared DateTimeFormat format.

Prototype

@SuppressWarnings("deprecation")
public String format(Date date, TimeZone timeZone) 

Source Link

Document

Format a date object using specified time zone.

Usage

From source file:com.smartgwt.mobile.client.json.JSONSerializer.java

License:Open Source License

@SGWTInternal
public static StringBuilder _appendQuotedFormTo(StringBuilder out, Object in, boolean strict,
        DateTimeFormat datetimeFormat) {
    if (in == null)
        return out.append("null");
    else if (in instanceof CharSequence)
        return _appendQuotedFormTo(out, (CharSequence) in, strict);
    else if (in instanceof Date) { // Special serialization for Dates
        final Date d = (Date) in;
        if (d instanceof LogicalDate) {
            out.append('"');
            ((LogicalDate) d).appendTo(out);
            out.append('"');
        } else if (d instanceof LogicalTime) {
            out.append('"');
            ((LogicalTime) d).appendTo(out);
            out.append('"');
        } else {//  w  ww  .j av  a2  s  . co  m
            _appendQuotedFormTo(out, datetimeFormat.format(d, UTC), strict);
        }
        return out;
    } else if (in instanceof ValueEnum)
        return _appendQuotedFormTo(out, ((ValueEnum) in).getValue(), strict);
    else if (in instanceof Boolean || in instanceof Number)
        return out.append(in);
    return _appendQuotedFormTo(out, in.toString(), strict);
}