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

Commit d8eca2b

Browse files
committed
Nicer formatting for Duration
1 parent 93d2e07 commit d8eca2b

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
@@ -67,6 +67,16 @@ public void tearDown() throws Exception
6767
shell.execute( "MATCH (n) DETACH DELETE (n)" );
6868
}
6969

70+
@Test
71+
public void parseDuration() throws CommandException
72+
{
73+
//when
74+
shell.execute( "RETURN duration({months:0.75})" );
75+
76+
//then
77+
assertThat( linePrinter.output(), containsString( "P22DT19H51M49.5S" ) );
78+
}
79+
7080
@Test
7181
public void cypherWithNoReturnStatements() throws CommandException
7282
{

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;
@@ -210,6 +211,8 @@ default String formatValue( final Value value )
210211
return pathAsString( value.asPath() );
211212
case POINT:
212213
return pointAsString( value.asPoint() );
214+
case DURATION:
215+
return DurationValue.parse( value.toString() ).prettyPrint();
213216
case ANY:
214217
case BOOLEAN:
215218
case BYTES:
@@ -222,7 +225,6 @@ default String formatValue( final Value value )
222225
case DATE_TIME:
223226
case LOCAL_TIME:
224227
case LOCAL_DATE_TIME:
225-
case DURATION:
226228
case NULL:
227229
default:
228230
return value.toString();

0 commit comments

Comments
 (0)