Here you can find the source of getDayWeekDate(String dateStr)
public static Date getDayWeekDate(String dateStr) throws ParseException
//package com.java2s; /**//from w w w . j ava2s . co m * License: https://github.com/votingsystem/votingsystem/wiki/Licencia */ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { private static final DateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); public static Date getDayWeekDate(String dateStr) throws ParseException { try { return getDateFromString(dateStr, "dd MMM yyyy' 'HH:mm"); } catch (Exception ex) { Calendar resultCalendar = Calendar.getInstance(); resultCalendar.setTime(getDateFromString(dateStr, "EEE dd MMM' 'HH:mm")); resultCalendar.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); return resultCalendar.getTime(); } } public static Date getDateFromString(String dateString) throws ParseException { if (dateString.endsWith("Z")) return isoDateFormat.parse(dateString); else { DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); return formatter.parse(dateString); } } public static Date getDateFromString(String dateString, Locale locale) throws ParseException { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); return formatter.parse(dateString); } public static Date getDateFromString(String dateString, String format) throws ParseException { DateFormat formatter = new SimpleDateFormat(format); return formatter.parse(dateString); } }