Java Calendar Create getCalendarTypeForString(String oneChar)

Here you can find the source of getCalendarTypeForString(String oneChar)

Description

get Calendar Type For String

License

Open Source License

Declaration

public static int getCalendarTypeForString(String oneChar) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com
 * 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://from   w  w w. j a  v a2  s .c  o  m
 *    emil.crumhorn@gmail.com - initial API and implementation
 *******************************************************************************/

import java.util.Calendar;

public class Main {
    public static int getCalendarTypeForString(String oneChar) {

        int calType = -1;

        switch (oneChar.charAt(0)) {
        case 'G':
            calType = Calendar.ERA;
            break;
        case 'y':
            calType = Calendar.YEAR;
            break;
        case 'M':
            calType = Calendar.MONTH;
            break;
        case 'd':
            calType = Calendar.DAY_OF_MONTH;
            break;
        case 'E':
            calType = Calendar.DAY_OF_WEEK;
            break;
        case 'D':
            calType = Calendar.DAY_OF_YEAR;
            break;
        case 'F':
            calType = Calendar.DATE;
            break;
        case 'h':
            calType = Calendar.HOUR;
            break;
        case 'm':
            calType = Calendar.MINUTE;
            break;
        case 's':
            calType = Calendar.SECOND;
            break;
        case 'S':
            calType = Calendar.MILLISECOND;
            break;
        case 'w':
            calType = Calendar.WEEK_OF_YEAR;
            break;
        case 'W':
            calType = Calendar.WEEK_OF_MONTH;
            break;
        case 'a':
            calType = Calendar.AM_PM;
            break;
        case 'k':
            calType = Calendar.HOUR_OF_DAY;
            break;
        case 'K':
            // ?
            break;
        case 'z':
            calType = Calendar.ZONE_OFFSET;
            break;
        }

        return calType;
    }
}

Related

  1. getCalendarInstance()
  2. getCalendarOf(int slot)
  3. getCalendarRange(Calendar date, int i)
  4. getCalendarTime(long timestamp)
  5. getCalendarTodayZero(Calendar today)
  6. getLocalCalendar()
  7. getLocalCalendar()