BAEL-10944 Added logic of returning fixed date time zone in HelloResource

This commit is contained in:
Dhawal Kapil 2019-02-26 17:52:54 +05:30
parent d6dc3f9941
commit 4be7eaf419
4 changed files with 7 additions and 5 deletions

View File

@ -3,6 +3,8 @@ package restx.demo.rest;
import restx.demo.domain.Message; import restx.demo.domain.Message;
import restx.demo.Roles; import restx.demo.Roles;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import restx.annotations.GET; import restx.annotations.GET;
import restx.annotations.POST; import restx.annotations.POST;
import restx.annotations.RestxResource; import restx.annotations.RestxResource;
@ -29,7 +31,7 @@ public class HelloResource {
return new Message().setMessage(String.format( return new Message().setMessage(String.format(
"hello %s, it's %s", "hello %s, it's %s",
RestxSession.current().getPrincipal().get().getName(), RestxSession.current().getPrincipal().get().getName(),
DateTime.now().toString("HH:mm:ss"))); DateTime.now(DateTimeZone.UTC).toString("HH:mm:ss")));
} }
/** /**
@ -44,7 +46,7 @@ public class HelloResource {
public Message helloPublic(String who) { public Message helloPublic(String who) {
return new Message().setMessage(String.format( return new Message().setMessage(String.format(
"hello %s, it's %s", "hello %s, it's %s",
who, DateTime.now().toString("HH:mm:ss"))); who, DateTime.now(DateTimeZone.UTC).toString("HH:mm:ss")));
} }
public static class MyPOJO { public static class MyPOJO {

View File

@ -7,4 +7,4 @@ wts:
GET message GET message
$RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"admin","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"} $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"admin","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
then: | then: |
{"message":"hello admin, it's 04:48:00"} {"message":"hello admin, it's 23:18:00"}

View File

@ -5,4 +5,4 @@ wts:
- when: | - when: |
GET hello?who=xavier GET hello?who=xavier
then: | then: |
{"message":"hello xavier, it's 04:48:00"} {"message":"hello xavier, it's 23:18:00"}

View File

@ -7,4 +7,4 @@ wts:
GET message GET message
$RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"user1","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"} $RestxSession: {"_expires":"2013-09-27T01:18:00.822+02:00","principal":"user1","sessionKey":"e2b4430f-9541-4602-9a3a-413d17c56a6b"}
then: | then: |
{"message":"hello user1, it's 04:48:00"} {"message":"hello user1, it's 23:18:00"}