Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
87239ba6
Commit
87239ba6
authored
Mar 09, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse build.time as an ISO 8601 instant
Closes gh-12420
parent
252ef3fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
BuildProperties.java
...n/java/org/springframework/boot/info/BuildProperties.java
+5
-5
BuildPropertiesTests.java
...a/org/springframework/boot/info/BuildPropertiesTests.java
+7
-4
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/BuildProperties.java
View file @
87239ba6
...
...
@@ -16,9 +16,9 @@
package
org
.
springframework
.
boot
.
info
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.DateTimeException
;
import
java.time.Instant
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Properties
;
/**
...
...
@@ -89,12 +89,12 @@ public class BuildProperties extends InfoProperties {
private
static
void
coerceDate
(
Properties
properties
,
String
key
)
{
String
value
=
properties
.
getProperty
(
key
);
if
(
value
!=
null
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssZ"
);
try
{
String
updatedValue
=
String
.
valueOf
(
format
.
parse
(
value
).
getTime
());
String
updatedValue
=
String
.
valueOf
(
DateTimeFormatter
.
ISO_INSTANT
.
parse
(
value
,
Instant:
:
from
).
toEpochMilli
());
properties
.
setProperty
(
key
,
updatedValue
);
}
catch
(
Pars
eException
ex
)
{
catch
(
DateTim
eException
ex
)
{
// Ignore and store the original value
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/info/BuildPropertiesTests.java
View file @
87239ba6
...
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
info
;
import
java.time.Instant
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Properties
;
import
org.junit.Test
;
...
...
@@ -31,14 +33,15 @@ public class BuildPropertiesTests {
@Test
public
void
basicInfo
()
{
Instant
instant
=
Instant
.
now
();
BuildProperties
properties
=
new
BuildProperties
(
createProperties
(
"com.example"
,
"demo"
,
"0.0.1"
,
"2016-03-04T14:36:33+0100"
));
"demo"
,
"0.0.1"
,
DateTimeFormatter
.
ISO_INSTANT
.
format
(
instant
)
));
assertThat
(
properties
.
getGroup
()).
isEqualTo
(
"com.example"
);
assertThat
(
properties
.
getArtifact
()).
isEqualTo
(
"demo"
);
assertThat
(
properties
.
getVersion
()).
isEqualTo
(
"0.0.1"
);
assertThat
(
properties
.
getTime
()).
is
NotNull
(
);
assertThat
(
properties
.
get
(
"time"
))
.
isEqualTo
(
"1457098593000"
);
assertThat
(
properties
.
getTime
().
toEpochMilli
()).
isEqualTo
(
1457098593000L
);
assertThat
(
properties
.
getTime
()).
is
EqualTo
(
instant
);
assertThat
(
properties
.
get
(
"time"
))
.
isEqualTo
(
String
.
valueOf
(
instant
.
toEpochMilli
())
);
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment