Java Date to Day getDay(Date date)

Here you can find the source of getDay(Date date)

Description

get Day

License

Open Source License

Declaration

public static int getDay(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oobium, Inc.//  w  w  w . java  2  s  .  co  m
 * 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:
 *     Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation
 ******************************************************************************/

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int getDay() {
        return getField(new Date(), Calendar.DAY_OF_MONTH);
    }

    public static int getDay(Date date) {
        return getField(date, Calendar.DAY_OF_MONTH);
    }

    public static int getField(Date date, int field) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.get(field);
    }

    public static int getField(int field) {
        return getField(new Date(), field);
    }
}

Related

  1. getDay(Date date)
  2. getDay(Date date)
  3. getDay(Date date)
  4. getDay(Date date)
  5. getDay(Date date)
  6. getDay(Date date)
  7. getDay(Date date, int day)
  8. getDay(Date dateParam)
  9. getDay(java.util.Date date)