cdate在java中_Java SimpleDateFormat.toPattern方法代码示例

本文整理汇总了Java中java.text.SimpleDateFormat.toPattern方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleDateFormat.toPattern方法的具体用法?Java SimpleDateFormat.toPattern怎么用?Java SimpleDateFormat.toPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.SimpleDateFormat的用法示例。

在下文中一共展示了SimpleDateFormat.toPattern方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDateInstance

​点赞 2

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

*

Gets a date formatter instance using the specified style, time

* zone and locale.

*

* @param style date style: FULL, LONG, MEDIUM, or SHORT

* @param timeZone optional time zone, overrides time zone of

* formatted date

* @param locale optional locale, overrides system locale

* @return a localized standard date formatter

* @throws IllegalArgumentException if the Locale has no date

* pattern defined

*/

public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale) {

Object key = new Integer(style);

if (timeZone != null) {

key = new Pair(key, timeZone);

}

if (locale == null) {

locale = Locale.getDefault();

}

key = new Pair(key, locale);

FastDateFormat format = (FastDateFormat) cDateInstanceCache.get(key);

if (format == null) {

try {

SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale);

String pattern = formatter.toPattern();

format = getInstance(pattern, timeZone, locale);

cDateInstanceCache.put(key, format);

} catch (ClassCastException ex) {

throw new IllegalArgumentException("No date pattern for locale: " + locale);

}

}

return format;

}

开发者ID:lamsfoundation,项目名称:lams,代码行数:39,

示例2: getTimeInstance

​点赞 2

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

*

Gets a time formatter instance using the specified style, time

* zone and locale.

*

* @param style time style: FULL, LONG, MEDIUM, or SHORT

* @param timeZone optional time zone, overrides time zone of

* formatted time

* @param locale optional locale, overrides system locale

* @return a localized standard time formatter

* @throws IllegalArgumentException if the Locale has no time

* pattern defined

*/

public static synchronized FastDateFormat getTimeInstance(int style, TimeZone timeZone, Locale locale) {

Object key = new Integer(style);

if (timeZone != null) {

key = new Pair(key, timeZone);

}

if (locale != null) {

key = new Pair(key, locale);

}

FastDateFormat format = (FastDateFormat) cTimeInstanceCache.get(key);

if (format == null) {

if (locale == null) {

locale = Locale.getDefault();

}

try {

SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getTimeInstance(style, locale);

String pattern = formatter.toPattern();

format = getInstance(pattern, timeZone, locale);

cTimeInstanceCache.put(key, format);

} catch (ClassCastException ex) {

throw new IllegalArgumentException("No date pattern for locale: " + locale);

}

}

return format;

}

开发者ID:lamsfoundation,项目名称:lams,代码行数:40,

示例3: getDateTimeInstance

​点赞 2

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

*

Gets a date/time formatter instance using the specified style,

* time zone and locale.

*

* @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT

* @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT

* @param timeZone optional time zone, overrides time zone of

* formatted date

* @param locale optional locale, overrides system locale

* @return a localized standard date/time formatter

* @throws IllegalArgumentException if the Locale has no date/time

* pattern defined

*/

public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone,

Locale locale) {

Object key = new Pair(new Integer(dateStyle), new Integer(timeStyle));

if (timeZone != null) {

key = new Pair(key, timeZone);

}

if (locale == null) {

locale = Locale.getDefault();

}

key = new Pair(key, locale);

FastDateFormat format = (FastDateFormat) cDateTimeInstanceCache.get(key);

if (format == null) {

try {

SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,

locale);

String pattern = formatter.toPattern();

format = getInstance(pattern, timeZone, locale);

cDateTimeInstanceCache.put(key, format);

} catch (ClassCastException ex) {

throw new IllegalArgumentException("No date time pattern for locale: " + locale);

}

}

return format;

}

开发者ID:lamsfoundation,项目名称:lams,代码行数:41,

示例4: parseValue

​点赞 2

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

private Object parseValue(Path path, Object value) {

if (Date.class.isAssignableFrom(path.getJavaType())) {

try {

SimpleDateFormat dateFormat = this.dateFormat != null ? this.dateFormat : defaultDateFormat;

value = dateFormat.parse(value.toString());

} catch (ParseException e) {

throw new SpecificationException("Illegal date format: " + value + ", required format is " + dateFormat.toPattern());

}

}

return value;

}

开发者ID:ZhongjunTian,项目名称:spring-repository-plus,代码行数:12,

示例5: parse

​点赞 2

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

* Parse the text with the format and locale specified

*

* @param text the text to parse

* @param format the date format, see {@link java.text.SimpleDateFormat} for more information

* @param locale the locale

* @return the parsed date

* @throws ParserException if the text cannot be parsed

*/

public Date parse(String text, String format, Locale locale) throws ParserException {

SimpleDateFormat dateFormat = getDateFormat(format, locale);

try {

return dateFormat.parse(text.trim());

} catch (ParseException e) {

throw new ParserException("Error when parsing date(" + dateFormat.toPattern() + ") from " + text, e);

}

}

开发者ID:dewey-its,项目名称:apollo-custom,代码行数:19,

示例6: getDateFormat

​点赞 1

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

* @param length

* the type of date format, e.g. {@link CachingDateFormat#LONG }

* @param locale

* the Locale that will be used to determine the

* date pattern

*

* @see #getDateFormat(String, boolean)

* @see CachingDateFormat#SHORT

* @see CachingDateFormat#MEDIUM

* @see CachingDateFormat#LONG

* @see CachingDateFormat#FULL

*/

public static SimpleDateFormat getDateFormat(int length, Locale locale, boolean lenient)

{

SimpleDateFormat dateFormat = (SimpleDateFormat) CachingDateFormat.getDateInstance(length, locale);

// extract the format string

String pattern = dateFormat.toPattern();

// we have a pattern to use

return getDateFormat(pattern, lenient);

}

开发者ID:Alfresco,项目名称:alfresco-core,代码行数:22,

示例7: getDateTimeFormat

​点赞 1

import java.text.SimpleDateFormat; //导入方法依赖的package包/类

/**

* @param dateLength

* the type of date format, e.g. {@link CachingDateFormat#LONG }

* @param timeLength

* the type of time format, e.g. {@link CachingDateFormat#LONG }

* @param locale

* the Locale that will be used to determine the

* date pattern

*

* @see #getDateFormat(String, boolean)

* @see CachingDateFormat#SHORT

* @see CachingDateFormat#MEDIUM

* @see CachingDateFormat#LONG

* @see CachingDateFormat#FULL

*/

public static SimpleDateFormat getDateTimeFormat(int dateLength, int timeLength, Locale locale, boolean lenient)

{

SimpleDateFormat dateFormat = (SimpleDateFormat) CachingDateFormat.getDateTimeInstance(dateLength, timeLength, locale);

// extract the format string

String pattern = dateFormat.toPattern();

// we have a pattern to use

return getDateFormat(pattern, lenient);

}

开发者ID:Alfresco,项目名称:alfresco-core,代码行数:24,

注:本文中的java.text.SimpleDateFormat.toPattern方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值