Fix methods in ScheduleFormat and NetworkFormat
This commit is contained in:
parent
1c291b3142
commit
a70ac82141
3 changed files with 13 additions and 9 deletions
|
@ -33,10 +33,10 @@ public final class NetworkFormat {
|
|||
|
||||
private static final DateTimeFormatter DURATION_FORMATTER = DateTimeFormatter
|
||||
.ofPattern("HH:mm:ss");
|
||||
private static final NumberFormat DURATION_SECONDS_FORMATTER = NumberFormat
|
||||
private static final NumberFormat DURATION_INDIVIDUAL_FORMATTER = NumberFormat
|
||||
.getIntegerInstance(Locale.ENGLISH);
|
||||
static {
|
||||
DURATION_SECONDS_FORMATTER.setMinimumIntegerDigits(2);
|
||||
DURATION_INDIVIDUAL_FORMATTER.setMinimumIntegerDigits(2);
|
||||
}
|
||||
private static final Temporal ZERO = LocalTime.parse("00:00:00");
|
||||
|
||||
|
@ -51,8 +51,8 @@ public final class NetworkFormat {
|
|||
}
|
||||
|
||||
public static String formatDuration(Duration duration) {
|
||||
return Long.toString(duration.toMinutes()) + ":"
|
||||
+ DURATION_SECONDS_FORMATTER.format(duration.toSecondsPart());
|
||||
return DURATION_INDIVIDUAL_FORMATTER.format(duration.toMinutes()) + ":"
|
||||
+ DURATION_INDIVIDUAL_FORMATTER.format(duration.toSecondsPart());
|
||||
}
|
||||
|
||||
/** Get a formatter for the numbers in a GPS coordinate pair
|
||||
|
|
|
@ -5,6 +5,7 @@ package fr.u_paris.gla.project.io;
|
|||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.ResolverStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -32,11 +33,14 @@ public final class ScheduleFormat {
|
|||
* @return the sequence of branching
|
||||
*/
|
||||
public static List<Integer> getTripSequence(String representation) {
|
||||
// TODO Read a trip sequence from a string
|
||||
|
||||
throw new RuntimeException("Not implemented yet");
|
||||
List<Integer> l = new ArrayList<>();
|
||||
for(String s : representation.split(","))
|
||||
l.add(Integer.parseInt(s));
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
public static DateTimeFormatter getTimeFormatter() {
|
||||
return DateTimeFormatter.ofPattern("HH:mm").withResolverStyle(ResolverStyle.LENIENT);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
class ScheduleFormatTest {
|
||||
|
||||
@Test
|
||||
void getTripSequence() {
|
||||
String rpz = "4, 5, 19, 21";
|
||||
public void getTripSequence() {
|
||||
String rpz = "4,5,19,21";
|
||||
List<Integer> test = Arrays.asList(4, 5, 19, 21);
|
||||
|
||||
assertEquals(test, ScheduleFormat.getTripSequence(rpz));
|
||||
|
|
Reference in a new issue