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
673a08d2
Commit
673a08d2
authored
Jul 02, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support microseconds in Duration conversions
Closes gh-13624
parent
06a8c419
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
0 deletions
+26
-0
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-0
DurationStyle.java
.../java/org/springframework/boot/convert/DurationStyle.java
+5
-0
DurationStyleTests.java
.../org/springframework/boot/convert/DurationStyleTests.java
+12
-0
StringToDurationConverterTests.java
...ramework/boot/convert/StringToDurationConverterTests.java
+8
-0
No files found.
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
673a08d2
...
...
@@ -1263,6 +1263,7 @@ read timeout of 500ms can be specified in any of the following form: `500`, `PT0
You can also use any of the supported unit. These are:
* `ns` for nanoseconds
* `us` for microseconds
* `ms` for milliseconds
* `s` for seconds
* `m` for minutes
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationStyle.java
View file @
673a08d2
...
...
@@ -180,6 +180,11 @@ public enum DurationStyle {
*/
NANOS
(
ChronoUnit
.
NANOS
,
"ns"
,
Duration:
:
toNanos
),
/**
* Microseconds.
*/
MICROS
(
ChronoUnit
.
MICROS
,
"us"
,
(
duration
)
->
duration
.
toMillis
()
*
1000L
),
/**
* Milliseconds.
*/
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/DurationStyleTests.java
View file @
673a08d2
...
...
@@ -71,6 +71,18 @@ public class DurationStyleTests {
.
isEqualTo
(
Duration
.
ofNanos
(-
10
));
}
@Test
public
void
detectAndParseWhenSimpleMicrosShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10us"
))
.
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
DurationStyle
.
detectAndParse
(
"10US"
))
.
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
DurationStyle
.
detectAndParse
(
"+10us"
))
.
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
DurationStyle
.
detectAndParse
(
"-10us"
))
.
isEqualTo
(
Duration
.
ofNanos
(-
10000
));
}
@Test
public
void
detectAndParseWhenSimpleMillisShouldReturnDuration
()
{
assertThat
(
DurationStyle
.
detectAndParse
(
"10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
));
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/StringToDurationConverterTests.java
View file @
673a08d2
...
...
@@ -70,6 +70,14 @@ public class StringToDurationConverterTests {
assertThat
(
convert
(
"-10ns"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10
));
}
@Test
public
void
convertWhenSimpleMicrosShouldReturnDuration
()
{
assertThat
(
convert
(
"10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
convert
(
"10US"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
convert
(
"+10us"
)).
isEqualTo
(
Duration
.
ofNanos
(
10000
));
assertThat
(
convert
(
"-10us"
)).
isEqualTo
(
Duration
.
ofNanos
(-
10000
));
}
@Test
public
void
convertWhenSimpleMillisShouldReturnDuration
()
{
assertThat
(
convert
(
"10ms"
)).
isEqualTo
(
Duration
.
ofMillis
(
10
));
...
...
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