Here you can find the source of formatDateTime(String s)
public static String formatDateTime(String s)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); you may public class Main { public static String formatDateTime(String s) { //if string still contains a space after trim, assume it is the wrong format //if it doesn't contain a space, it's probably good to go if (!s.contains(" ")) return s; return s.trim().replace(" ", "T") + "Z"; }//from ww w . ja v a2 s. co m }