public static String generateDatabaseId(String baseString) {
    checkArgument(baseString.length() != 0, "baseString cannot be empty!");

    String databaseId =
        generateResourceId(
            baseString,
            ILLEGAL_DATABASE_CHARS,
            REPLACE_DATABASE_CHAR,
            MAX_DATABASE_ID_LENGTH,
            DATABASE_TIME_FORMAT);

    // replace hyphen with underscore, so there's no need for backticks
    String trimmed = CharMatcher.is('_').trimTrailingFrom(databaseId);

    checkArgument(
        trimmed.length() > 0,
        "Database id is empty after removing illegal characters and trailing underscores");

    // if first char is not a letter, replace with a padding letter, so it doesn't
    // violate spanner's database naming rules
    char padding = generatePadding();
    if (!Character.isLetter(trimmed.charAt(0))) {
      trimmed = padding + trimmed.substring(1);
    }
    return trimmed;
  }
@Test
  public void testGenerateDatabaseIdShouldReplaceDotWithUnderscore() {
    String testBaseString = "test.database";

    String actual = generateDatabaseId(testBaseString);

    assertThat(actual).matches("test_da_\\d{8}_\\d{6}_\\d{6}");
  }