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


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 ("days").length() > 0) {
        		days = Integer.parseInt("days"));
        	hours += Integer.parseInt("hours"));
        	minutes += Integer.parseInt("minutes"));
        	seconds += Integer.parseInt("seconds"));
        	if ("ms").length() > 0) {
        		ms = Integer.parseInt("ms"));


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.