ServiceStack.Java Support for the standard .Net format for TimeSpan?

Hi,

my application is configured to use the standard .Net format for TimeSpan (0.00:00:00) instead of the xsd duration format (JsConfig.TimeSpanHandler = TimeSpanHandler.StandardFormat;). Can you extend the TimeSpan.parse method to support the .Net format? A small regex could help with this issue:

int days = 0;
        int hours = 0;
        int minutes = 0;
        int seconds = 0;
        double ms = 0.0;

        Pattern p = Pattern.compile("^(?<days>\\d*)?.?(?<hours>\\d\\d)\\:(?<minutes>\\d\\d)\\:(?<seconds>\\d\\d).?(?<ms>\\d*)?$$"); // matches 2.00:00:00, 00:00:00, 00:00:00.234 or 2.00:00:00.123
        Matcher m = p.matcher("2.05:22:11.123");
        if (m.matches()){
        	if (m.group("days").length() > 0) {
        		days = Integer.parseInt(m.group("days"));
        	}
        	hours += Integer.parseInt(m.group("hours"));
        	minutes += Integer.parseInt(m.group("minutes"));
        	seconds += Integer.parseInt(m.group("seconds"));
        	if (m.group("ms").length() > 0) {
        		ms = Integer.parseInt(m.group("ms"));
        	}
        }

Thanks

I don’t want complicate each Native Type provider by adding support for non-default customizations, adding extra complexity, increasing surface area for interoperability issues and feature disparity across all native providers. You can add a feature request for it so it can be considered later.

In the meantime have a look at this earlier answer on how you can customize the Java Gson serialization handling of different types in your own Application.

Thanks, I’ll create a feature request for that.