@Test public void testExtractSeparatorsForDifferentLocales() throws Throwable { DatePicker datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "M/d/y"; } }; List<CharSequence> actualSeparators = datePicker.extractSeparators(); List<String> expectedSeparators = Arrays.asList(new String[]{"", "/", "/", ""}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "y/M/d"; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"", "/", "/", ""}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "d/M/y"; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"", "/", "/", ""}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "d. M. y"; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"", ".", ".", ""}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "dd. MM. y."; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"", ".", ".", "."}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "d.MM.y 'r'."; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"", ".", ".", "r."}); assertEquals(expectedSeparators, actualSeparators); datePicker = new DatePicker(mContext, null) { @Override String getBestYearMonthDayPattern(String datePickerFormat) { return "[M/d/y]"; } }; actualSeparators = datePicker.extractSeparators(); expectedSeparators = Arrays.asList(new String[]{"[", "/", "/", "]"}); assertEquals(expectedSeparators, actualSeparators); }
List<CharSequence> extractSeparators() { String hmaPattern = getBestYearMonthDayPattern(mDatePickerFormat); List<CharSequence> separators = new ArrayList<>(); StringBuilder sb = new StringBuilder(); char lastChar = '\0'; final char[] dateFormats = {'Y', 'y', 'M', 'm', 'D', 'd'}; boolean processingQuote = false; for (int i = 0; i < hmaPattern.length(); i++) { char c = hmaPattern.charAt(i); if (c == ' ') { continue; } if (c == '\'') { if (!processingQuote) { sb.setLength(0); processingQuote = true; } else { processingQuote = false; } continue; } if (processingQuote) { sb.append(c); } else { if (isAnyOf(c, dateFormats)) { if (c != lastChar) { separators.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } lastChar = c; } separators.add(sb.toString()); return separators; }
DatePicker extends Picker { List<CharSequence> extractSeparators() { String hmaPattern = getBestYearMonthDayPattern(mDatePickerFormat); List<CharSequence> separators = new ArrayList<>(); StringBuilder sb = new StringBuilder(); char lastChar = '\0'; final char[] dateFormats = {'Y', 'y', 'M', 'm', 'D', 'd'}; boolean processingQuote = false; for (int i = 0; i < hmaPattern.length(); i++) { char c = hmaPattern.charAt(i); if (c == ' ') { continue; } if (c == '\'') { if (!processingQuote) { sb.setLength(0); processingQuote = true; } else { processingQuote = false; } continue; } if (processingQuote) { sb.append(c); } else { if (isAnyOf(c, dateFormats)) { if (c != lastChar) { separators.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } lastChar = c; } separators.add(sb.toString()); return separators; } }
DatePicker extends Picker { List<CharSequence> extractSeparators() { String hmaPattern = getBestYearMonthDayPattern(mDatePickerFormat); List<CharSequence> separators = new ArrayList<>(); StringBuilder sb = new StringBuilder(); char lastChar = '\0'; final char[] dateFormats = {'Y', 'y', 'M', 'm', 'D', 'd'}; boolean processingQuote = false; for (int i = 0; i < hmaPattern.length(); i++) { char c = hmaPattern.charAt(i); if (c == ' ') { continue; } if (c == '\'') { if (!processingQuote) { sb.setLength(0); processingQuote = true; } else { processingQuote = false; } continue; } if (processingQuote) { sb.append(c); } else { if (isAnyOf(c, dateFormats)) { if (c != lastChar) { separators.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } lastChar = c; } separators.add(sb.toString()); return separators; } DatePicker(Context context, AttributeSet attrs);  DatePicker(Context context, AttributeSet attrs, int defStyleAttr); }
DatePicker extends Picker { List<CharSequence> extractSeparators() { String hmaPattern = getBestYearMonthDayPattern(mDatePickerFormat); List<CharSequence> separators = new ArrayList<>(); StringBuilder sb = new StringBuilder(); char lastChar = '\0'; final char[] dateFormats = {'Y', 'y', 'M', 'm', 'D', 'd'}; boolean processingQuote = false; for (int i = 0; i < hmaPattern.length(); i++) { char c = hmaPattern.charAt(i); if (c == ' ') { continue; } if (c == '\'') { if (!processingQuote) { sb.setLength(0); processingQuote = true; } else { processingQuote = false; } continue; } if (processingQuote) { sb.append(c); } else { if (isAnyOf(c, dateFormats)) { if (c != lastChar) { separators.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } lastChar = c; } separators.add(sb.toString()); return separators; } DatePicker(Context context, AttributeSet attrs);  DatePicker(Context context, AttributeSet attrs, int defStyleAttr); void setDatePickerFormat(String datePickerFormat); String getDatePickerFormat(); @Override final void onColumnValueChanged(int column, int newVal); void setMinDate(long minDate); long getMinDate(); void setMaxDate(long maxDate); long getMaxDate(); long getDate(); void updateDate(int year, int month, int dayOfMonth, boolean animation); }
DatePicker extends Picker { List<CharSequence> extractSeparators() { String hmaPattern = getBestYearMonthDayPattern(mDatePickerFormat); List<CharSequence> separators = new ArrayList<>(); StringBuilder sb = new StringBuilder(); char lastChar = '\0'; final char[] dateFormats = {'Y', 'y', 'M', 'm', 'D', 'd'}; boolean processingQuote = false; for (int i = 0; i < hmaPattern.length(); i++) { char c = hmaPattern.charAt(i); if (c == ' ') { continue; } if (c == '\'') { if (!processingQuote) { sb.setLength(0); processingQuote = true; } else { processingQuote = false; } continue; } if (processingQuote) { sb.append(c); } else { if (isAnyOf(c, dateFormats)) { if (c != lastChar) { separators.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } lastChar = c; } separators.add(sb.toString()); return separators; } DatePicker(Context context, AttributeSet attrs);  DatePicker(Context context, AttributeSet attrs, int defStyleAttr); void setDatePickerFormat(String datePickerFormat); String getDatePickerFormat(); @Override final void onColumnValueChanged(int column, int newVal); void setMinDate(long minDate); long getMinDate(); void setMaxDate(long maxDate); long getMaxDate(); long getDate(); void updateDate(int year, int month, int dayOfMonth, boolean animation);  }