-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update time service to have a textual version of date/time
- Loading branch information
1 parent
d82c4d6
commit 299ec34
Showing
2 changed files
with
20 additions
and
5 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
chapter4/time/src/main/java/ejm.chapter4.time/TimeResource.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ejm.chapter4.time; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
/** | ||
* @author Ken Finnigan | ||
*/ | ||
@Path("/") | ||
public class TimeResource { | ||
private DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; | ||
|
||
@GET | ||
public String getTime() { | ||
return formatter.format(ZonedDateTime.now()); | ||
} | ||
} |