code: static String[] getBackups(File origin) {
      File root = origin.getParentFile();
      final String originName = origin.getName();
      
      String[] backups = root.list(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
          if (!name.startsWith(originName + File.pathSeparator)
              || name.equals(originName))
            return false;
          try {
            dateForm.get().parse(name.substring(name.indexOf(File.pathSeparator) + 1));
          } catch (ParseException pex) {
            return false;
          }
          return true;
        }
      });
      if (backups == null)
        return new String[0];
  
      Arrays.sort(backups, new Comparator<String>() {
  
        @Override
        public int compare(String back1, String back2) {
          try {
            Date date1 = dateForm.get().parse(back1.substring(back1
                .indexOf(File.pathSeparator) + 1));
            Date date2 = dateForm.get().parse(back2.substring(back2
                .indexOf(File.pathSeparator) + 1));
            // Sorting in reverse order, from later dates to earlier
            return -1 * date2.compareTo(date1);
          } catch (ParseException pex) {
            return 0;
          }
        }
      });
      return backups;
    }
docs: List all directories that match the backup pattern.
  Sort from oldest to newest.