Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fengjueding
spring-framework
提交
f0d21510
S
spring-framework
项目概览
fengjueding
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f0d21510
编写于
12月 30, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
Issue: SPR-11259
上级
5e00113c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
16 deletion
+15
-16
spring-context/src/main/java/org/springframework/format/datetime/DateFormatterRegistrar.java
...ringframework/format/datetime/DateFormatterRegistrar.java
+5
-5
spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java
...work/format/datetime/joda/JodaTimeFormatterRegistrar.java
+1
-1
spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java
...ndard/Jsr310DateTimeFormatAnnotationFormatterFactory.java
+3
-3
spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
...mework/core/convert/support/GenericConversionService.java
+4
-5
spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionTests.java
...ramework/core/convert/support/DefaultConversionTests.java
+2
-2
未找到文件。
spring-context/src/main/java/org/springframework/format/datetime/DateFormatterRegistrar.java
浏览文件 @
f0d21510
...
...
@@ -60,7 +60,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
// In order to retain back compatibility we only register Date/Calendar
// types when a user defined formatter is specified (see SPR-10105)
if
(
this
.
dateFormatter
!=
null
)
{
if
(
this
.
dateFormatter
!=
null
)
{
registry
.
addFormatter
(
this
.
dateFormatter
);
registry
.
addFormatterForFieldType
(
Calendar
.
class
,
this
.
dateFormatter
);
}
...
...
@@ -113,7 +113,7 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
@Override
public
Long
convert
(
Calendar
source
)
{
return
source
.
getTime
().
getTime
();
return
source
.
getTime
InMillis
();
}
}
...
...
@@ -129,11 +129,11 @@ public class DateFormatterRegistrar implements FormatterRegistrar {
private
static
class
LongToCalendarConverter
implements
Converter
<
Long
,
Calendar
>
{
private
final
DateToCalendarConverter
dateToCalendarConverter
=
new
DateToCalendarConverter
();
@Override
public
Calendar
convert
(
Long
source
)
{
return
this
.
dateToCalendarConverter
.
convert
(
new
Date
(
source
));
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
source
);
return
calendar
;
}
}
...
...
spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java
浏览文件 @
f0d21510
...
...
@@ -187,7 +187,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
// In order to retain backwards compatibility we only register Date/Calendar
// types when a user defined formatter is specified (see SPR-10105)
if
(
this
.
formatters
.
containsKey
(
Type
.
DATE_TIME
))
{
if
(
this
.
formatters
.
containsKey
(
Type
.
DATE_TIME
))
{
addFormatterForFields
(
registry
,
new
ReadableInstantPrinter
(
dateTimeFormatter
),
new
DateTimeParser
(
dateTimeFormatter
),
...
...
spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java
浏览文件 @
f0d21510
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -92,10 +92,10 @@ public class Jsr310DateTimeFormatAnnotationFormatterFactory
}
/**
* Factory method used to create a {@link
org.joda.time.format.
DateTimeFormatter}.
* Factory method used to create a {@link DateTimeFormatter}.
* @param annotation the format annotation for the field
* @param fieldType the type of field
* @return a {@link
org.joda.time.format.
DateTimeFormatter} instance
* @return a {@link DateTimeFormatter} instance
*/
protected
DateTimeFormatter
getFormatter
(
DateTimeFormat
annotation
,
Class
<?>
fieldType
)
{
DateTimeFormatterFactory
factory
=
new
DateTimeFormatterFactory
();
...
...
spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
浏览文件 @
f0d21510
...
...
@@ -456,6 +456,7 @@ public class GenericConversionService implements ConfigurableConversionService {
}
}
/**
* Manages all converters registered with the service.
*/
...
...
@@ -614,12 +615,10 @@ public class GenericConversionService implements ConfigurableConversionService {
this
.
converters
.
addFirst
(
converter
);
}
public
GenericConverter
getConverter
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
public
GenericConverter
getConverter
(
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
for
(
GenericConverter
converter
:
this
.
converters
)
{
if
(!(
converter
instanceof
ConditionalGenericConverter
)
||
((
ConditionalGenericConverter
)
converter
).
matches
(
sourceType
,
targetType
))
{
if
(!(
converter
instanceof
ConditionalGenericConverter
)
||
((
ConditionalGenericConverter
)
converter
).
matches
(
sourceType
,
targetType
))
{
return
converter
;
}
}
...
...
spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionTests.java
浏览文件 @
f0d21510
...
...
@@ -209,7 +209,7 @@ public class DefaultConversionTests {
}
@Test
public
void
testStringToEnumWithSubclss
()
throws
Exception
{
public
void
testStringToEnumWithSubcl
a
ss
()
throws
Exception
{
assertEquals
(
SubFoo
.
BAZ
,
conversionService
.
convert
(
"BAZ"
,
SubFoo
.
BAR
.
getClass
()));
}
...
...
@@ -224,7 +224,7 @@ public class DefaultConversionTests {
}
public
static
enum
Foo
{
BAR
,
BAZ
;
BAR
,
BAZ
}
public
static
enum
SubFoo
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录