Skip to content

Instantly share code, notes, and snippets.

@dan-dm
Created May 15, 2020 22:22
Show Gist options
  • Save dan-dm/29ca7a3312e454234e5284591c389c78 to your computer and use it in GitHub Desktop.
Save dan-dm/29ca7a3312e454234e5284591c389c78 to your computer and use it in GitHub Desktop.
Created with Copy to Gist
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