I have a class called DateFormatter, which currently lives in both the
client and server directories, because I haven't found a way to do
what it does within a single file, or rather what I want it to do
within a single file.
Here's what the code looks like on the server side:
******************************************************************************************************
(package name removed)
import java.text.DateFormat;
public class DateFormatter {
private static final DateFormat dateFormatter =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static final Date timeToDate(String time) {
Date date = null;
try {
date = dateFormatter.parse(time);
} catch(ParseException e) {}
return date;
}
public static final String dateToTime(Date date) {
return dateFormatter.format(date);
}
}
******************************************************************************************************
...and here's the code on the client side:
******************************************************************************************************
package org.codingventures.blog.client;
import com.google.gwt.i18n.client.DateTimeFormat;
public class DateFormatter {
private static DateTimeFormat dateFormatter =
DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
public static final Date timeToDate(String time) {
Date date = null;
try {
date = dateFormatter.parse(time);
} catch(IllegalArgumentException e) {}
return date;
}
public static final String dateToTime(Date date) {
return dateFormatter.format(date);
}
}
******************************************************************************************************
Currently this is breaking just about everything because the client
code won't run on the server and the server code won't run on the
client. This _wouldn't_ be an issue but because I have serializable
classes being sent across GWT's RPC which have to use one of these I'm
running into a lot of problems.
So, is there a way to combine these classes?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---