get Week Of Date - Java java.util

Java examples for java.util:Week

Description

get Week Of Date

Demo Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getWeekOfDate());
    }//from  ww  w.ja  va  2s . c  om

    public static int getWeekOfDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int w = calendar.get(Calendar.DAY_OF_WEEK);
        if (w < 0) {
            w = 0;
        }
        return w;
    }
}

Related Tutorials