Created
May 15, 2020 22:22
-
-
Save dan-dm/29ca7a3312e454234e5284591c389c78 to your computer and use it in GitHub Desktop.
Created with Copy to Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
public class Item { | |
private String name; | |
private LocalDateTime createdAt; | |
public Item(String name) { | |
this.name = name; | |
this.createdAt = LocalDateTime.now(); | |
} | |
public String getName() { | |
return name; | |
} | |
@Override | |
public String toString() { | |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss"); | |
return this.name + " (created at: " + formatter.format(this.createdAt) + ")"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment