Here you can find the source of getDayNameForDate(java.util.Date dt, boolean fullname)
Parameter | Description |
---|---|
dt | The date. |
fullname | Fetch complete day's name or the short one. <p> |
public static String getDayNameForDate(java.util.Date dt, boolean fullname)
//package com.java2s; /*/* ww w . j a va2 s. c o m*/ * DateHelper.java * * Copyright (c) 2004-2011 Gregory Kotsaftis * gregkotsaftis@yahoo.com * http://zeus-jscl.sourceforge.net/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.text.SimpleDateFormat; public class Main { /** * Gets the name of a day based on a date and current locale. * <p> * * @param dt * The date. * @param fullname * Fetch complete day's name or the short one. * <p> * @return A string with the name of the day. */ public static String getDayNameForDate(java.util.Date dt, boolean fullname) { // For formatting, if the number of pattern letters is 4 or more, // the full form is used; otherwise a short or abbreviated form is used // if available. (extracted from Sun's Javadoc) final String fullFormat = "EEEE"; final String smallFormat = "EEE"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(fullname ? fullFormat : smallFormat); String dayName = simpleDateFormat.format(dt); return (dayName); } }