Date time library for gwt

前端 未结 2 1882
死守一世寂寞
死守一世寂寞 2020-11-29 11:40

I am working on a gwt application which involves advanced manipulations with date times: convert from one timezone to another, etc. Gwt has some low level stuff for working

相关标签:
2条回答
  • 2020-11-29 11:53

    You could look at the following options.

    http://code.google.com/p/gwt-time/

    http://code.google.com/p/goda-time/

    http://github.com/mping/gwt-joda-time

    0 讨论(0)
  • 2020-11-29 11:55

    This is my DateTimeUtil class

    public class DateTimeUtil {
        public static String getYear(Date date) {
            return DateTimeFormat.getFormat("yyyy").format(date);
        }
        public static String getMonth(Date date) {
            return DateTimeFormat.getFormat("MM").format(date);
        }
        public static String getDay(Date date) {
            return DateTimeFormat.getFormat("dd").format(date);
        }
        public static String getHour(Date date) {
            return DateTimeFormat.getFormat("HH").format(date);
        }
        public static String getMinute(Date date) {
            return DateTimeFormat.getFormat("mm").format(date);
        }
        public static String getSecond(Date date) {
            return DateTimeFormat.getFormat("ss").format(date);
        }
    
        // The String year must to have yyyy format
    
        public static Date getDate(String years, String months, String days, String hours, String minutes, String seconds) {
            DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
            Date date = dtf.parse(years + "-" + months + "-" + days + " " + hours + ":" + minutes + ":" + seconds);
            GWT.log("date parsed " + date);
            return date;
        }
    }
    
    0 讨论(0)
提交回复
热议问题