Skip to content

Instantly share code, notes, and snippets.

@unclejamal
Created September 18, 2013 20:43
Show Gist options
  • Save unclejamal/6615383 to your computer and use it in GitHub Desktop.
Save unclejamal/6615383 to your computer and use it in GitHub Desktop.
@Path("time")
public class TimeResource {
private final Clock clock;
public TimeResource(Clock clock) {
this.clock = clock;
}
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getCurrentTime() {
return String.format("It's currently %s!", format(clock.now()));
}
private String format(Date now) {
return new SimpleDateFormat("HH:mm").format(now);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment