-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement [3463] Improved Date formatter #3466
base: 1.8
Are you sure you want to change the base?
Conversation
@@ -211,11 +212,16 @@ public static MetricNode fromThinString(String line) { | |||
* @return string format of this. | |||
*/ | |||
public String toFatString() { | |||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DateTimeFormatter 应该改成静态成员变量
private static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done made it as private static variable
|
||
LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); | ||
sb.append(dateTime.format(formatter)).append("|"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dateTime.format(formatter)改成 df.format(dataTime), 因为dateTime.format(formatter)内部就是调用的df.format(dataTime)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brucelwl made a changes.
Describe what this PR does / why we need it
Improvement for date formatter
Does this pull request fix one issue?
#3463 3463
Fixes #3463 3463
Describe how you did it
Changed to DateTimeFormatter from Java
Describe how to verify it
Special notes for reviews