Java: update intention description and example

GitOrigin-RevId: 22b8858e7c822bf1745ca644260703b5b2e7c599
This commit is contained in:
Bas Leijdekkers
2023-03-06 16:28:25 +01:00
committed by intellij-monorepo-bot
parent 5b120de0b7
commit b68439a0b3
3 changed files with 4 additions and 8 deletions

View File

@@ -2,12 +2,8 @@ import java.text.*;
import java.util.Date;
class X {
private static final ThreadLocal<DateFormat> dateFormat = new ThreadLocal<DateFormat>() {
@Override
protected DateFormat initialValue() {
return new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
}
};
private static final ThreadLocal<DateFormat> DATE_FORMAT =
ThreadLocal.withInitial(() -> new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"));
public String getDateString() {
return dateFormat.get().format(new Date());

View File

@@ -2,7 +2,7 @@ import java.text.*;
import java.util.Date;
public class X {
private static DateFormat <spot>dateFormat</spot> = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
private static final DateFormat <spot>DATE_FORMAT</spot> = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
public String getDateString() {
return dateFormat.format(new Date());

View File

@@ -1,5 +1,5 @@
<html>
<body>
Replaces a field type with a corresponding thread local.
Replaces a field type with a corresponding thread local type.
</body>
</html>