Here you can find the source of stripSubMillis(String iso8601string)
public static String stripSubMillis(String iso8601string)
//package com.java2s; // License: https://servicestack.net/bsd-license.txt public class Main { public final static int isoDateWithSubMsMin = "YYYY-MM-DDT00:00:00.0000+00:00".length(); public final static int isoDateWithSubMsMax = "YYYY-MM-DDT00:00:00.0000000+00:00".length(); public static String stripSubMillis(String iso8601string) { if (iso8601string.length() < isoDateWithSubMsMin || iso8601string.length() > isoDateWithSubMsMax) return iso8601string; String[] parts = splitOnFirst(iso8601string, '.'); String suffix = parts[1].substring(parts[1].length() - 6); //+00:00 String ms = parts[1].substring(0, 3); return parts[0] + "." + ms + suffix; }/* ww w . ja v a 2 s . c o m*/ public static String[] splitOnFirst(String strVal, char needle) { if (strVal == null) return new String[0]; int pos = strVal.indexOf(needle); return pos == -1 ? new String[] { strVal } : new String[] { strVal.substring(0, pos), strVal.substring(pos + 1) }; } public static String[] splitOnFirst(String strVal, String needle) { if (strVal == null) return new String[0]; int pos = strVal.indexOf(needle); return pos == -1 ? new String[] { strVal } : new String[] { strVal.substring(0, pos), strVal.substring(pos + needle.length()) }; } }