亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? datelocaleconverter.java

?? 這是一個有關common beanutils 的源碼
?? JAVA
字號:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.beanutils.locale.converters;

import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.locale.BaseLocaleConverter;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;

import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.util.Locale;


/**
 * <p>Standard {@link org.apache.commons.beanutils.locale.LocaleConverter} 
 * implementation that converts an incoming
 * locale-sensitive String into a <code>java.util.Date</code> object,
 * optionally using a default value or throwing a 
 * {@link org.apache.commons.beanutils.ConversionException}
 * if a conversion error occurs.</p>
 *
 * @author Yauheny Mikulski
 * @author Michael Szlapa
 */

public class DateLocaleConverter extends BaseLocaleConverter {

    // ----------------------------------------------------- Instance Variables

    /** All logging goes through this logger */
    private Log log = LogFactory.getLog(DateLocaleConverter.class);

    /** Should the date conversion be lenient? */
    boolean isLenient = false;

    /** 
     * Default Pattern Characters 
     * 
     */
    private static final String DEFAULT_PATTERN_CHARS = DateLocaleConverter.initDefaultChars();

    // ----------------------------------------------------------- Constructors

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs. The locale is the default locale for
     * this instance of the Java Virtual Machine and an unlocalized pattern is used
     * for the convertion.
     *
     */
    public DateLocaleConverter() {

        this(false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs. The locale is the default locale for
     * this instance of the Java Virtual Machine.
     *
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(boolean locPattern) {

        this(Locale.getDefault(), locPattern);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs. An unlocalized pattern is used for the convertion.
     *
     * @param locale        The locale
     */
    public DateLocaleConverter(Locale locale) {

        this(locale, false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs.
     *
     * @param locale        The locale
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(Locale locale, boolean locPattern) {

        this(locale, (String) null, locPattern);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs. An unlocalized pattern is used for the convertion.
     *
     * @param locale        The locale
     * @param pattern       The convertion pattern
     */
    public DateLocaleConverter(Locale locale, String pattern) {

        this(locale, pattern, false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will throw a {@link org.apache.commons.beanutils.ConversionException}
     * if a conversion error occurs.
     *
     * @param locale        The locale
     * @param pattern       The convertion pattern
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(Locale locale, String pattern, boolean locPattern) {

        super(locale, pattern, locPattern);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs. The locale is the default locale for
     * this instance of the Java Virtual Machine and an unlocalized pattern is used
     * for the convertion.
     *
     * @param defaultValue  The default value to be returned
     */
    public DateLocaleConverter(Object defaultValue) {

        this(defaultValue, false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs. The locale is the default locale for
     * this instance of the Java Virtual Machine.
     *
     * @param defaultValue  The default value to be returned
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(Object defaultValue, boolean locPattern) {

        this(defaultValue, Locale.getDefault(), locPattern);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs. An unlocalized pattern is used for the convertion.
     *
     * @param defaultValue  The default value to be returned
     * @param locale        The locale
     */
    public DateLocaleConverter(Object defaultValue, Locale locale) {

        this(defaultValue, locale, false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs.
     *
     * @param defaultValue  The default value to be returned
     * @param locale        The locale
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(Object defaultValue, Locale locale, boolean locPattern) {

        this(defaultValue, locale, null, locPattern);
    }


    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs. An unlocalized pattern is used for the convertion.
     *
     * @param defaultValue  The default value to be returned
     * @param locale        The locale
     * @param pattern       The convertion pattern
     */
    public DateLocaleConverter(Object defaultValue, Locale locale, String pattern) {

        this(defaultValue, locale, pattern, false);
    }

    /**
     * Create a {@link org.apache.commons.beanutils.locale.LocaleConverter} 
     * that will return the specified default value
     * if a conversion error occurs.
     *
     * @param defaultValue  The default value to be returned
     * @param locale        The locale
     * @param pattern       The convertion pattern
     * @param locPattern    Indicate whether the pattern is localized or not
     */
    public DateLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) {

        super(defaultValue, locale, pattern, locPattern);
    }

    // --------------------------------------------------------- Methods
    
    /**
     * Returns whether date formatting is lenient.
     *
     * @return true if the <code>DateFormat</code> used for formatting is lenient
     * @see java.text.DateFormat#isLenient
     */
    public boolean isLenient() {
        return isLenient;
    }
    
    /**
     * Specify whether or not date-time parsing should be lenient.
     * 
     * @param lenient true if the <code>DateFormat</code> used for formatting should be lenient
     * @see java.text.DateFormat#setLenient
     */
    public void setLenient(boolean lenient) {
        isLenient = lenient;
    }

    // --------------------------------------------------------- Methods

    /**
     * Convert the specified locale-sensitive input object into an output object of the
     * specified type.
     *
     * @param value The input object to be converted
     * @param pattern The pattern is used for the convertion
     * @return the converted Date value
     *
     * @exception org.apache.commons.beanutils.ConversionException 
     * if conversion cannot be performed successfully
     * @throws ParseException if an error occurs parsing
     */
    protected Object parse(Object value, String pattern) throws ParseException {
 
        // Handle Date
        if (value instanceof java.util.Date) {
            return value;
        }

        // Handle Calendar
        if (value instanceof java.util.Calendar) {
            return ((java.util.Calendar)value).getTime();
        }

         if (locPattern) {
             pattern = convertLocalizedPattern(pattern, locale);
         }
 
         // Create Formatter - use default if pattern is null
         DateFormat formatter = pattern == null ? DateFormat.getDateInstance(DateFormat.SHORT, locale)
                                                : new SimpleDateFormat(pattern, locale);
         formatter.setLenient(isLenient);
 

         // Parse the Date
        ParsePosition pos = new ParsePosition(0);
        String strValue = value.toString();
        Object parsedValue = formatter.parseObject(strValue, pos);
        if (pos.getErrorIndex() > -1) {
            throw new ConversionException("Error parsing date '" + value +
                    "' at position="+ pos.getErrorIndex());
        }
        if (pos.getIndex() < strValue.length()) {
            throw new ConversionException("Date '" + value +
                    "' contains unparsed characters from position=" + pos.getIndex());
        }

        return parsedValue;
     }
   
     /**
      * Convert a pattern from a localized format to the default format.
      *
      * @param locale   The locale
      * @param localizedPattern The pattern in 'local' symbol format
      * @return pattern in 'default' symbol format
      */
     private String convertLocalizedPattern(String localizedPattern, Locale locale) {
        
         if (localizedPattern == null) {
            return null;
         }
         
         // Note that this is a little obtuse.
         // However, it is the best way that anyone can come up with 
         // that works with some 1.4 series JVM.
         
         // Get the symbols for the localized pattern
         DateFormatSymbols localizedSymbols = new DateFormatSymbols(locale);
         String localChars = localizedSymbols.getLocalPatternChars();
 
         if (DEFAULT_PATTERN_CHARS.equals(localChars)) {
             return localizedPattern;
         }
 
         // Convert the localized pattern to default
         String convertedPattern = null;
         try {
             convertedPattern = convertPattern(localizedPattern,
                                                localChars,
                                                DEFAULT_PATTERN_CHARS);
         } catch (Exception ex) {
             log.debug("Converting pattern '" + localizedPattern + "' for " + locale, ex);
         }
         return convertedPattern; 
    }
     
    /**
     * <p>Converts a Pattern from one character set to another.</p>
     */
    private String convertPattern(String pattern, String fromChars, String toChars) {

        StringBuffer converted = new StringBuffer();
        boolean quoted = false;

        for (int i = 0; i < pattern.length(); ++i) {
            char thisChar = pattern.charAt(i);
            if (quoted) {
                if (thisChar == '\'') {
                    quoted = false;
                }
            } else {
                if (thisChar == '\'') {
                   quoted = true;
                } else if ((thisChar >= 'a' && thisChar <= 'z') || 
                           (thisChar >= 'A' && thisChar <= 'Z')) {
                    int index = fromChars.indexOf(thisChar );
                    if (index == -1) {
                        throw new IllegalArgumentException(
                            "Illegal pattern character '" + thisChar + "'");
                    }
                    thisChar = toChars.charAt(index);
                }
            }
            converted.append(thisChar);
        }

        if (quoted) {
            throw new IllegalArgumentException("Unfinished quote in pattern");
        }

        return converted.toString();
    }

    /**
     * This method is called at class initialization time to define the
     * value for constant member DEFAULT_PATTERN_CHARS. All other methods needing
     * this data should just read that constant.
     */
    private static String initDefaultChars() {
        DateFormatSymbols defaultSymbols = new DateFormatSymbols(Locale.US);
        return defaultSymbols.getLocalPatternChars();
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美激情小说另类| 国产91精品一区二区| 国产精品久久777777| 久久久精品中文字幕麻豆发布| 日韩视频在线永久播放| 欧美久久久久久久久久| 欧美日韩一区二区三区免费看| 在线观看亚洲a| 在线看国产日韩| 欧美女孩性生活视频| 欧美色中文字幕| 88在线观看91蜜桃国自产| 欧美性大战久久久| 欧美剧在线免费观看网站| 欧美日韩一区三区四区| 日韩欧美一区二区在线视频| 欧美一区二区三区小说| 欧美videofree性高清杂交| 精品成人免费观看| 亚洲国产精品v| 亚洲精品国产无天堂网2021| 亚洲福利一二三区| 欧美aa在线视频| 国产一区二区三区在线观看精品| 国产伦精品一区二区三区免费| 成人精品一区二区三区四区| 一本一本大道香蕉久在线精品 | 色国产精品一区在线观看| 色婷婷久久综合| 91麻豆精品国产91久久久久久 | 日韩欧美在线不卡| 久久久91精品国产一区二区三区| 国产精品热久久久久夜色精品三区 | 在线观看成人小视频| 欧美人与禽zozo性伦| 亚洲精品在线免费播放| 国产精品国产三级国产普通话99| 一区二区三区精品在线| 日本在线不卡一区| 国产成人精品在线看| 在线视频国内一区二区| 91精品国产一区二区三区| 国产欧美一区二区三区在线看蜜臀| 亚洲乱码中文字幕综合| 日本在线不卡视频一二三区| 处破女av一区二区| 欧美精品乱码久久久久久| 精品sm在线观看| 亚洲一区影音先锋| 国产一区二区精品久久99| 91毛片在线观看| 精品免费国产一区二区三区四区| 国产精品毛片大码女人| 日韩精品91亚洲二区在线观看| 成人高清视频在线| 制服丝袜亚洲精品中文字幕| 国产精品第四页| 老司机免费视频一区二区三区| 91视频你懂的| 久久色.com| 亚洲国产日日夜夜| 大陆成人av片| 日韩欧美一级特黄在线播放| 亚洲精品亚洲人成人网| 国产酒店精品激情| 欧美日韩成人综合天天影院 | 91免费观看在线| 欧美一区二区久久久| 亚洲欧洲性图库| 韩国视频一区二区| 欧美美女一区二区| 中文字幕一区av| 国产大陆a不卡| 欧美精品777| 一区二区三区美女视频| 国产1区2区3区精品美女| 日韩三级在线观看| 一二三区精品福利视频| 成人黄色网址在线观看| 精品嫩草影院久久| 爽好多水快深点欧美视频| 一本色道a无线码一区v| 国产欧美日韩另类视频免费观看| 日本v片在线高清不卡在线观看| 一本色道久久加勒比精品| 国产女同互慰高潮91漫画| 精品一区二区精品| 欧美日韩高清一区| 亚洲一区二区av电影| 91色在线porny| 中文字幕免费不卡在线| 国产酒店精品激情| 日韩精品一区二区三区swag| 偷拍一区二区三区四区| 91成人看片片| 亚洲一卡二卡三卡四卡五卡| 成人a免费在线看| 国产精品污www在线观看| 黄页网站大全一区二区| 日韩一区二区不卡| 久久国产精品99久久久久久老狼 | 最新日韩在线视频| 成人午夜伦理影院| 国产精品色一区二区三区| 国产精品2024| 中文字幕av一区 二区| 丁香五精品蜜臀久久久久99网站| 久久久影院官网| 国产精品99久久久| 久久精品夜色噜噜亚洲aⅴ| 国产乱理伦片在线观看夜一区| 久久亚洲二区三区| 国产乱人伦偷精品视频免下载| 26uuuu精品一区二区| 美女一区二区三区| 国产精品资源网站| 亚洲一区中文在线| 欧美网站一区二区| 亚洲大型综合色站| 日韩欧美一区二区三区在线| 精品影视av免费| 欧美国产日韩在线观看| 99久久精品久久久久久清纯| 亚洲精品网站在线观看| 欧美日韩中文另类| 日本视频免费一区| 久久综合狠狠综合久久综合88| 国产乱码精品一区二区三| 成人欧美一区二区三区1314| 一本到不卡免费一区二区| 亚洲综合精品自拍| 91精品国产手机| 国产综合色产在线精品| 国产目拍亚洲精品99久久精品| 99国产精品久| 91国产成人在线| 亚洲成av人片www| 精品免费视频一区二区| 成人av中文字幕| 有坂深雪av一区二区精品| 91精品欧美福利在线观看| 亚洲va欧美va国产va天堂影院| 国产精品1区二区.| 精品日韩av一区二区| 成人高清免费观看| 日日欢夜夜爽一区| 久久综合中文字幕| 色哟哟日韩精品| 久久99精品网久久| 亚洲欧洲色图综合| 日韩欧美亚洲一区二区| 成人一区二区在线观看| 国产一区二区按摩在线观看| 99久久婷婷国产精品综合| 欧美日韩另类一区| 国产成人免费视频一区| 一区二区三区免费| 久久久久久一二三区| 欧美综合久久久| 国产乱码一区二区三区| 亚洲国产精品自拍| 日本一区二区视频在线| 欧美三级韩国三级日本一级| 岛国一区二区三区| 美女视频黄免费的久久| 中文字幕欧美一区| 精品福利在线导航| 在线观看视频一区| 成人性生交大片免费看视频在线 | 风间由美一区二区三区在线观看 | 精品视频在线看| 国产成人av电影| 热久久国产精品| 亚洲女子a中天字幕| 精品国产91乱码一区二区三区 | 欧美国产精品v| 欧美一区二区三区视频免费播放| 成人国产免费视频| 国产自产高清不卡| 日韩av二区在线播放| 有码一区二区三区| 国产精品久久久久影院色老大 | 日精品一区二区三区| 亚洲欧美日韩在线不卡| 久久久亚洲欧洲日产国码αv| 欧美伊人久久久久久久久影院 | 国产成+人+日韩+欧美+亚洲| 青青青伊人色综合久久| 亚洲v日本v欧美v久久精品| 国产精品成人网| 国产精品情趣视频| 337p日本欧洲亚洲大胆精品| 91精品国产91久久久久久一区二区 | 色综合久久中文综合久久97 | 2024国产精品视频| 日韩一区二区在线播放| 欧美丰满一区二区免费视频 | 精品区一区二区| 日韩欧美美女一区二区三区| 日韩一区二区免费在线观看|