WearUtil { public static String joinSet(Set<String> set, String separator) { StringBuilder sb = new StringBuilder(); int i = 0; for (String item : set) { final String itemToAdd = item.trim(); if (itemToAdd.length() > 0) { if (i > 0) { sb.append(separator); } i++; sb.append(itemToAdd); } } return sb.toString(); }  static String dateTimeText(long timeInMs); static long timestamp(); static long msSince(long when); static long msTill(long when); static synchronized boolean isBelowRateLimit(String named, int onceForSeconds); static PowerManager.WakeLock getWakeLock(final String name, int millis); static void releaseWakeLock(PowerManager.WakeLock wl); static void startActivity(Class c); static Intent getStartActivityIntent(Class c); static void threadSleep(long millis); static String joinSet(Set<String> set, String separator); static Set<String> explodeSet(String joined, String separator); static DataMap bundleToDataMap(Bundle bundle);  }
@Test public void joinSetTest() { Set<String> refSet = new HashSet<>(); refSet.add("element1"); refSet.add("second-elem"); refSet.add("3rd"); String joined = WearUtil.joinSet(refSet, "|"); assertThat(joined.length(), is("element1".length() + "second-elem".length() + "3rd".length() + "|".length()*2 )); assertThat("|"+joined+"|", containsString("|"+"element1"+"|")); assertThat("|"+joined+"|", containsString("|"+"second-elem"+"|")); assertThat("|"+joined+"|", containsString("|"+"3rd"+"|")); }