get Day Of Week From Resource - Android java.util

Android examples for java.util:Week

Description

get Day Of Week From Resource

Demo Code


//package com.java2s;
import android.content.Context;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getDayOfWeekFromResource(Date date, Context context) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*from   w ww  .  j av a  2s  .c om*/
        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);

        String resourceName = context.getPackageName() + ":string/weekday_"
                + dayOfWeek;
        int resourceId = context.getResources().getIdentifier(resourceName,
                null, null);

        return context.getResources().getString(resourceId);
    }
}

Related Tutorials