Code example for Date

Methods: getDay, getMonth

0
     * @param date date to format 
     * @return date, with month, day, and year 
     */ 
    @SuppressWarnings("nls") 
    public static String getDateString(Context context, Date date, boolean includeYear) {
        String month = DateUtils.getMonthString(date.getMonth() +
                Calendar.JANUARY, DateUtils.LENGTH_MEDIUM);
        String value;
        String standardDate;
        // united states, you are special 
        Locale locale = Locale.getDefault();
        if (arrayBinaryContains(locale.getLanguage(), "ja", "ko", "zh")
                || arrayBinaryContains(locale.getCountry(),  "BZ", "CA", "KE", "MN" ,"US"))
            value = "'#' d'$'";
        else 
            value = "d'$' '#'";
        if (includeYear)
            value += ", yyyy";
        if (arrayBinaryContains(locale.getLanguage(), "ja", "zh")){
            standardDate = new SimpleDateFormat(value).format(date).replace("#", month).replace("$", "\u65E5"); //$NON-NLS-1$
        }else if ("ko".equals(Locale.getDefault().getLanguage())){
            standardDate = new SimpleDateFormat(value).format(date).replace("#", month).replace("$", "\uC77C"); //$NON-NLS-1$
        }else{ 
            standardDate = new SimpleDateFormat(value).format(date).replace("#", month).replace("$", "");
        } 
        return standardDate;}
 
    public static String getDateString(Context context, Date date) {
        return getDateString(context, date, true);
    } 
 
    /** 
     * @param context android context 
     * @param date date to format 
     * @return date, with month, day, and year 
     */ 
    @SuppressWarnings("nls") 
    public static String getDateStringHideYear(Context context, Date date) {
        String month = DateUtils.getMonthString(date.getMonth() +
                Calendar.JANUARY, DateUtils.LENGTH_MEDIUM);
        String value;
        Locale locale = Locale.getDefault();
        // united states, you are special 
        if (arrayBinaryContains(locale.getLanguage(), "ja", "ko", "zh")
                || arrayBinaryContains(locale.getCountry(),  "BZ", "CA", "KE", "MN" ,"US"))
            value = "'#' d";
        else 
            value = "d '#'";
 
        if (date.getYear() !=  (new Date()).getYear()) {
            value = value + "\nyyyy";
        } 
        if (arrayBinaryContains(locale.getLanguage(), "ja", "zh")) //$NON-NLS-1$
            return new SimpleDateFormat(value).format(date).replace("#", month) + "\u65E5"; //$NON-NLS-1$
        else if ("ko".equals(Locale.getDefault().getLanguage())) //$NON-NLS-1$
            return new SimpleDateFormat(value).format(date).replace("#", month) + "\uC77C"; //$NON-NLS-1$
        else 
            return new SimpleDateFormat(value).format(date).replace("#", month);
    } 
 
    /** 
     * @return date format as getDateFormat with weekday 
     */ 
    @SuppressWarnings("nls") 
    public static String getDateStringWithWeekday(Context context, Date date) {
        String weekday = getWeekday(date);
        return weekday + ", " + getDateString(context, date);
    } 
 
    /** 
     * @return weekday 
     */ 
    public static String getWeekday(Date date) {
        return DateUtils.getDayOfWeekString(date.getDay() + Calendar.SUNDAY,
                DateUtils.LENGTH_LONG);
    } 
 
 
    /**