get Week Int as day of week - Android java.util

Android examples for java.util:Week

Description

get Week Int as day of week

Demo Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.util.Log;

public class Main {

    public static int getWeekInt(Date curDate) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String pTime = format.format(curDate);
        Calendar c = Calendar.getInstance();
        try {/*from www .j a  v a2  s .co  m*/
            c.setTime(format.parse(pTime));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return c.get(Calendar.DAY_OF_WEEK);
    }
}

Related Tutorials