Here you can find the source of formatDate(String dateTimeString)
Parameter | Description |
---|---|
dateTimeString | in format 2012-10-15T08:17:00 |
public static String formatDate(String dateTimeString)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**/* ww w. j a va 2s .c o m*/ *Extracts date and month from dateTimeString and formats * @param dateTimeString in format 2012-10-15T08:17:00 * @return format dd/MM * */ public static String formatDate(String dateTimeString) { SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss"); Date date = null; try { date = dateFormat.parse(dateTimeString); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); cal.setTime(date); String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); String month = String.valueOf(cal.get(Calendar.MONTH) + 1); return day + "/" + month; } }