Created
September 18, 2013 20:43
-
-
Save unclejamal/6615383 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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