Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions javakdb/src/main/java/com/kx/c.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ public Minute(int x){
}
@Override
public String toString(){
return i==ni?"":i2(i/60)+":"+i2(i%60);
if(i==ni)
return "";
int a=Math.abs(i);
return (i<0?"-":"")+i2(a/60)+":"+i2(a%60);
}
@Override
public boolean equals(final Object o){
Expand Down Expand Up @@ -527,7 +530,10 @@ public Second(int x){
}
@Override
public String toString(){
return i==ni?"":new Minute(i/60).toString()+':'+i2(i%60);
if(i==ni)
return "";
int a=Math.abs(i);
return (i<0?"-":"")+new Minute(a/60).toString()+':'+i2(a%60);
}
@Override
public boolean equals(final Object o){
Expand Down
12 changes: 12 additions & 0 deletions javakdb/src/test/java/com/kx/CTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,12 @@ public void testMinuteToString()
{
c.Minute mon = new c.Minute(22);
Assert.assertEquals("00:22", mon.toString());
mon = new c.Minute(1500);
Assert.assertEquals("25:00", mon.toString()); // minute can exceed 24h
mon = new c.Minute(-30);
Assert.assertEquals("-00:30", mon.toString());
mon = new c.Minute(-90);
Assert.assertEquals("-01:30", mon.toString());
mon = new c.Minute(Integer.MIN_VALUE);
Assert.assertEquals("", mon.toString());
}
Expand Down Expand Up @@ -1022,6 +1028,12 @@ public void testSecondToString()
{
c.Second mon = new c.Second(22);
Assert.assertEquals("00:00:22", mon.toString());
mon = new c.Second(90000);
Assert.assertEquals("25:00:00", mon.toString()); // second can exceed 24h
mon = new c.Second(-30);
Assert.assertEquals("-00:00:30", mon.toString());
mon = new c.Second(-3661);
Assert.assertEquals("-01:01:01", mon.toString());
mon = new c.Second(Integer.MIN_VALUE);
Assert.assertEquals("", mon.toString());
}
Expand Down