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 with dates but they are too low level for me. Are there any options similar to joda time or threeten for gwt?
Asked
Active
Viewed 8,541 times
12
-
did you end up using joda time in your gwt app? – Justin Jul 06 '12 at 02:54
-
@Justin Actually, I wrote my own library tailored to my specific needs :-) – Konstantin Solomatov Jul 06 '12 at 06:58
2 Answers
5
You could look at the following options.
http://code.google.com/p/gwt-time/

krishnakumarp
- 8,967
- 3
- 49
- 55
-
14
-
yes. sadly these seems to be the only options right now. I read that gwt-time is pretty useful on gwt issue list http://code.google.com/p/google-web-toolkit/issues/detail?id=603#c63 – krishnakumarp Apr 25 '12 at 09:59
-
3This answer its pretty oudated, for Date operations you can use GWT Calendarutil: http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/datepicker/client/CalendarUtil.html – Chepech Feb 06 '14 at 20:27
1
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;
}
}

teteArg
- 3,684
- 2
- 20
- 18