TimeFormat.java :  » GWT » gwtoolbox » org » gwtoolbox » commons » types » client » Java Open Source

Java Open Source » GWT » gwtoolbox 
gwtoolbox » org » gwtoolbox » commons » types » client » TimeFormat.java
package org.gwtoolbox.commons.types.client;

import com.google.gwt.i18n.client.DateTimeFormat;

import java.util.Date;

/**
 * @author Uri Boness
 */
public class TimeFormat {

    private DateTimeFormat format;

    public static TimeFormat getFormat(String pattern) {
        return new TimeFormat(pattern);
    }

    private TimeFormat(String pattern) {
        format = DateTimeFormat.getFormat(pattern);
    }

    public String format(Time time) {
        Date date = new Date(time.getTime());
        date.setTime(date.getTime() + date.getTimezoneOffset() * Time.MINUTE);
        return format.format(date);
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.