Here you can find the source of formatDateTime(String dateTime)
public static String formatDateTime(String dateTime)
//package com.java2s; /*/* w w w .ja v a 2 s . c om*/ * SSHTools - Globus Online Tool * * Copyright (C) 2013 Siew Hoon Leong * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * You may also distribute it and/or modify it under the terms of the * Apache style J2SSH Software License. A copy of which should have * been provided with the distribution. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * License document supplied with your distribution for more details. * */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDateTime(String dateTime) { try { dateTime = dateTime.substring(0, 22) + dateTime.substring(23, 25); String pattern = "yyyy-MM-dd HH:mm:ssZ"; SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date date = sdf.parse(dateTime); String newPattern = "dd MMM yyyy h:mm aaa zzz"; SimpleDateFormat myFormat = new SimpleDateFormat(newPattern); return myFormat.format(date); } catch (ParseException e) { } return dateTime; } }