Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(String dateInput) { try { SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = sdfSource.parse(dateInput); SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MM-yyyy"); dateInput = sdfDestination.format(date); return dateInput.toString(); } catch (ParseException pe) { return dateInput; } } }