Skip to content
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

Open
wants to merge 3 commits into
base: 1.8
Choose a base branch
from

Conversation

manojks1999
Copy link

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

@@ -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");

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");

Copy link
Author

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("|");

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brucelwl made a changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MetricNode#toFatString 时间转换影响性能
2 participants