I have a little problem and I hope someone can help me to solve it. I
have a class which used on client and server side, mainly to parse
Strings into Dates...
So I use on client side the com.google.gwt.i18n.client.DateTimeFormat
and on server side the java.text.SimpleDateFormat. The code of the
class got more and more and I don't want to have the same class (the
only different is really this one formatting part) on client and
server side... Is there a way to do a switch like:
Date parsed = null;
if (GWT.isScript()) {
com.google.gwt.i18n.client.DateTimeFormat formatter =
com.google.gwt.i18n.client.DateTimeFormat.getFormat(this.getFormat());
parsed = formatter.parse(value);
} else {
java.text.SimpleDateFormat formatter = new
java.text.SimpleDateFormat(this.getFormat());
parsed = formatter.parse(value);
}
This way does not work, cause the GWT Compiler does not see that it
will always be true and skip the second part... on server side this
would work fine (I guess) cause isScript would be false, so the
annoying GWT.create() error would not be raised... but is there some
way to get such a switch?
Thanks!