Skip to content

Commit

Permalink
ParserUtils: Add different separators for Date/Time formats
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Sep 4, 2016
1 parent 2c2889d commit 2be2937
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions parser/src/main/java/me/vertretungsplan/parser/ParserUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,28 @@ class ParserUtils {
"dd.MM.yyyy",
"dd.MM"
};
private static String[] separators = new String[]{
" ",
", "
};
private static String[] timeFormats = new String[]{
" HH:mm",
" (HH:mm 'Uhr')"
"HH:mm",
"(HH:mm 'Uhr')"
};
private static String[] dateTimeFormats = new String[dateFormats.length * timeFormats.length];
private static String[] dateTimeFormats = new String[dateFormats.length * timeFormats.length * separators.length];

static {
int i = 0;
for (String date : dateFormats) {
dateFormatters.add(DateTimeFormat.forPattern(date)
.withLocale(Locale.GERMAN).withDefaultYear(DateTime.now().getYear()));
for (String time : timeFormats) {
dateTimeFormats[i] = date + time;
dateTimeFormatters.add(DateTimeFormat.forPattern(date + time)
.withLocale(Locale.GERMAN).withDefaultYear(DateTime.now().getYear()));
i++;
for (String separator : separators) {
dateTimeFormats[i] = date + separator + time;
dateTimeFormatters.add(DateTimeFormat.forPattern(dateTimeFormats[i])
.withLocale(Locale.GERMAN).withDefaultYear(DateTime.now().getYear()));
i++;
}
}
}
}
Expand Down

0 comments on commit 2be2937

Please sign in to comment.