Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 03c6d25

Browse files
authored
Merge pull request #270 from pontusmelke/4.0-duration-format
Nicer formatting for Duration
2 parents a908498 + 0b94d55 commit 03c6d25

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellVerboseIntegrationTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ public void tearDown() throws Exception
7474
shell.execute( "MATCH (n) DETACH DELETE (n)" );
7575
}
7676

77+
@Test
78+
public void parseDuration() throws CommandException
79+
{
80+
//when
81+
shell.execute( "RETURN duration({months:0.75})" );
82+
83+
//then
84+
assertThat( linePrinter.output(), containsString( "P22DT19H51M49.5S" ) );
85+
}
86+
7787
@Test
7888
public void cypherWithNoReturnStatements() throws CommandException
7989
{

cypher-shell/src/main/java/org/neo4j/shell/prettyprint/OutputFormatter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.neo4j.driver.types.Point;
4040
import org.neo4j.driver.types.Relationship;
4141
import org.neo4j.shell.state.BoltResult;
42+
import org.neo4j.values.storable.DurationValue;
4243

4344
import static java.util.Arrays.asList;
4445
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -205,6 +206,8 @@ default String formatValue( final Value value )
205206
return pathAsString( value.asPath() );
206207
case POINT:
207208
return pointAsString( value.asPoint() );
209+
case DURATION:
210+
return DurationValue.parse( value.toString() ).prettyPrint();
208211
case ANY:
209212
case BOOLEAN:
210213
case BYTES:
@@ -217,7 +220,6 @@ default String formatValue( final Value value )
217220
case DATE_TIME:
218221
case LOCAL_TIME:
219222
case LOCAL_DATE_TIME:
220-
case DURATION:
221223
case NULL:
222224
default:
223225
return value.toString();

0 commit comments

Comments
 (0)