Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Main { public static String formatTime(String date, String format, String destFormat) { try { DateFormat format1 = new SimpleDateFormat(format); DateFormat format2 = new SimpleDateFormat(destFormat); return format2.format(format1.parse(date)); } catch (Exception e) { e.printStackTrace(); } return null; } }