Java tutorial
//package com.java2s; /** * Transform date or time to various formats * * @copyright Copyright (C) 2012 - 2013 Information Technology Institute ITI-CERTH. All rights reserved. * @license GNU Affero General Public License version 3 or later; see LICENSE.txt * @author Dimitrios Ververidis for the Multimedia Group (http://mklab.iti.gr). * */ import java.text.DateFormatSymbols; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; import android.content.res.Configuration; import android.text.format.DateUtils; public class Main { /** * Convert "YYYY-MM-DD" to "Friday X Month Year" * * @param Date_In * @param conf * @return */ public static String dateNum2STR(String Date_In, Configuration conf) { String DayNo_STR = Date_In.substring(8, 10); int DayNo = Integer.parseInt(DayNo_STR); String MonthNo_STR = Date_In.substring(5, 7); int MonthNo = Integer.parseInt(MonthNo_STR); String Month_STR = formatMonth(Integer.parseInt(MonthNo_STR), conf.locale); String Year_STR = Date_In.substring(0, 4); int Year = Integer.parseInt(Year_STR); Calendar myCal = new GregorianCalendar(Year, MonthNo - 1, DayNo); int dayOfWeek = myCal.get(Calendar.DAY_OF_WEEK); // 6=Friday String dayOfWeek_STR = DateUtils.getDayOfWeekString(dayOfWeek, DateUtils.LENGTH_MEDIUM); return dayOfWeek_STR + " " + DayNo_STR + " " + Month_STR + " " + Year_STR; } /** * Convert 2 to February * * @param month * @param locale * @return */ public static String formatMonth(int month, Locale locale) { DateFormatSymbols symbols = new DateFormatSymbols(locale); String[] monthNames = symbols.getMonths(); return monthNames[month - 1]; } }