{{#todos}}{{#capitalize}}{{title}}{{/capitalize}}
- Created on {{createdOn}}
- Lambda: {{#handleDone}}{{doneSince}}{{/handleDone}} :-)
- Done: {{done}}
{{text}}
{{/todos}} {{^todos}}No todos found
{{/todos}}import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.github.mustachejava.DefaultMustacheFactory; import com.github.mustachejava.Mustache; import com.github.mustachejava.MustacheFactory; import java.time.Duration; import java.util.function.Function; public class HtmlExporter { public static class Todo { public Todo() { createdOn = new Date(); } public Todo(String title, String text) { this.title = title; this.text = text; createdOn = new Date(); } private String title; private String text; private boolean done = false; private Date createdOn; private Date completedOn; public void markAsDone() { done = true; completedOn = new Date(); } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getText() { return text; } public void setText(String text) { this.text = text; } public boolean getDone() { return done; } public Date getCreatedOn() { return createdOn; } public Date getCompletedOn() { return completedOn; } public void setDone(boolean done) { this.done = done; } public void setCompletedOn(Date completedOn) { this.completedOn = completedOn; } public long doneSince() { return done ? Duration .between(createdOn.toInstant(), completedOn.toInstant()) .toMinutes() : 0; } public Function
No comments:
Post a Comment