get Last Day Of Week - Java java.util

Java examples for java.util:Week

Description

get Last Day Of Week

Demo Code

/*******************************************************************************
 * Copyright (c) 2004, 2009 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://ww  w. j  a v a 2 s .  c o  m
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/
//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar cal = Calendar.getInstance();
        System.out.println(getLastDayOfWeek(cal));
    }

    public static int getLastDayOfWeek(Calendar cal) {
        int last = cal.getFirstDayOfWeek() - 1;

        if (last == 0) {
            last = Calendar.SATURDAY;
        }

        return last;
    }
}

Related Tutorials