private static SuggestedFix threadLocalFix(
      VariableTree tree, VisitorState state, VarSymbol sym, SuggestedFix rename) {
    SuggestedFix.Builder fix =
        rename.toBuilder()
            .replace(
                tree.getType(),
                String.format("ThreadLocal<%s>", state.getSourceForNode(tree.getType())))
            .prefixWith(tree.getInitializer(), "ThreadLocal.withInitial(() -> ")
            .postfixWith(tree.getInitializer(), ")");
    CompilationUnitTree unit = state.getPath().getCompilationUnit();
    unit.accept(
        new TreeScanner<Void, Void>() {
          @Override
          public Void visitIdentifier(IdentifierTree tree, Void unused) {
            if (Objects.equals(ASTHelpers.getSymbol(tree), sym)) {
              fix.postfixWith(tree, ".get()");
            }
            return null;
          }
        },
        null);
    return fix.build();
  }
@Test
  public void threadLocalFix() {
    BugCheckerRefactoringTestHelper.newInstance(DateFormatConstant.class, getClass())
        .addInputLines(
            "in/Test.java",
            "import java.text.SimpleDateFormat;",
            "import java.text.DateFormat;",
            "import java.util.Date;",
            "class Test {",
            "  private static final DateFormat DATE_FORMAT =",
            "    new SimpleDateFormat(\"yyyy-MM-dd HH:mm\");",
            "  static String f(Date d) {",
            "    return DATE_FORMAT.format(d);",
            "  }",
            "}")
        .addOutputLines(
            "out/Test.java",
            "import java.text.SimpleDateFormat;",
            "import java.text.DateFormat;",
            "import java.util.Date;",
            "class Test {",
            "  private static final ThreadLocal<DateFormat> dateFormat = ",
            "    ThreadLocal.withInitial(() -> new SimpleDateFormat(\"yyyy-MM-dd HH:mm\"));",
            "  static String f(Date d) {",
            "    return dateFormat.get().format(d);",
            "  }",
            "}")
        .doTest();
  }