Java Calendar Create getCalendarField(char c)

Here you can find the source of getCalendarField(char c)

Description

get Calendar Field

License

Open Source License

Declaration

public static int getCalendarField(char c) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oobium, Inc./*  w  ww  .  j  a  va  2  s. c  o 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;

public class Main {
    public static int getCalendarField(char c) {
        switch (c) {
        case 'y':
            return Calendar.YEAR;
        case 'M':
            return Calendar.MONTH;
        case 'D':
            return Calendar.DAY_OF_YEAR;
        case 'd':
            return Calendar.DAY_OF_MONTH;
        case 'H':
            return Calendar.HOUR_OF_DAY;
        case 'k':
            return Calendar.HOUR_OF_DAY;
        case 'h':
            return Calendar.HOUR;
        case 'K':
            return Calendar.HOUR;
        case 'm':
            return Calendar.MINUTE;
        case 's':
            return Calendar.SECOND;
        case 'S':
            return Calendar.MILLISECOND;
        case 'a':
            return Calendar.AM_PM;
        default:
            return -1;
        }
    }
}

Related

  1. getCalendarByValue(String timeZone)
  2. getCalendarDate()
  3. getCalendarDate(Calendar calendar)
  4. getCalendarDateFromToday(final int numDays)
  5. getCalendarDayString(Calendar date)
  6. getCalendarField(Date date, int calFieldId)
  7. getCalendarFieldName(int field)
  8. getCalendarFormYear(int year)
  9. getCalendarForNextRun( GregorianCalendar startTime, int targetDay, int targetHour)