week Floor - Java java.util

Java examples for java.util:Week

Description

week Floor

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar calendar = Calendar.getInstance();
        weekFloor(calendar);/*from   w  w  w.ja  v  a 2 s .  c  o m*/
    }

    public static void weekFloor(Calendar calendar) {
        int i = calendar.get(Calendar.YEAR);
        int k = calendar.get(Calendar.DAY_OF_YEAR);
        int l = calendar.get(Calendar.DAY_OF_WEEK);
        int i1 = calendar.getFirstDayOfWeek();
        int j1 = l - i1;
        if (j1 > 0) {
            k -= j1;
        } else if (j1 < 0) {
            k -= 7 + j1;
        }
        calendar.clear();
        boolean flag = calendar.isLenient();
        if (!flag) {
            calendar.setLenient(true);
        }
        calendar.set(Calendar.YEAR, i);
        calendar.set(Calendar.DAY_OF_YEAR, k);
        if (!flag) {
            int j = calendar.get(Calendar.YEAR);
            calendar.setLenient(false);
        }
    }
}

Related Tutorials