diff --git a/src/main/java/org/javarosa/core/model/utils/DateUtils.java b/src/main/java/org/javarosa/core/model/utils/DateUtils.java index a013a0eb66..5267c47049 100755 --- a/src/main/java/org/javarosa/core/model/utils/DateUtils.java +++ b/src/main/java/org/javarosa/core/model/utils/DateUtils.java @@ -336,7 +336,9 @@ public static String format(DateFields f, String format) { } else if (c == 'a') { //Three letter short text day String[] dayNames = new String[]{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; sb.append(dayNames[f.dow - 1]); - } else if (Arrays.asList('c', 'C', 'D', 'F', 'g', 'G', 'I', 'j', 'k', 'l', 'p', 'P', 'r', 'R', 's', 't', 'T', 'u', 'U', 'V', 'w', 'W', 'x', 'X', 'z', 'Z').contains(c)) { + } else if (c == 'w') { //Day of the week (0 through 6), Sunday being 0. + sb.append(f.dow - 1); + } else if (Arrays.asList('c', 'C', 'D', 'F', 'g', 'G', 'I', 'j', 'k', 'l', 'p', 'P', 'r', 'R', 's', 't', 'T', 'u', 'U', 'V', 'W', 'x', 'X', 'z', 'Z').contains(c)) { // Format specifiers supported by libc's strftime: https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html throw new RuntimeException("unsupported escape in date format string [%" + c + "]"); } else { diff --git a/src/test/java/org/javarosa/core/model/utils/test/DateUtilsTests.java b/src/test/java/org/javarosa/core/model/utils/test/DateUtilsTests.java index 85109674e4..d082bc99fd 100644 --- a/src/test/java/org/javarosa/core/model/utils/test/DateUtilsTests.java +++ b/src/test/java/org/javarosa/core/model/utils/test/DateUtilsTests.java @@ -197,6 +197,7 @@ public void testFormat() { escapesResults.put("%B", "November"); escapesResults.put("%d", "05"); escapesResults.put("%e", "5"); + escapesResults.put("%w", "6"); for (String escape : escapesResults.keySet()) { String result = escapesResults.get(escape);