方法一:
public static void DateTimeToString(String expr, String formatstr ,LocalDateTime now) {
String re = expr;
expr = "12345";
Field valueFieldOfString = null;
try {
valueFieldOfString = String.class.getDeclaredField("value");
valueFieldOfString.setAccessible(true);
valueFieldOfString.set(re,expr.toCharArray());
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
方法二:使用 StringBuffuer ? StringBuilder ?