Here you can find the source of getWeekday(Date d)
Parameter | Description |
---|---|
d | a parameter |
public static int getWeekday(Date d)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 BSI Business Systems Integration AG. * 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 va2 s . com * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /** * determines the day of the week * * @param d * @return int with the the day of the week (sunday=1) */ public static int getWeekday(Date d) { if (d == null) { return -1; } Calendar cal = Calendar.getInstance(); cal.setTime(d); int w = cal.get(Calendar.DAY_OF_WEEK); return w; } }