[struts] branch master updated: WW-5016 Support java8 date/time in date tag
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/master by this push: new aacac5b WW-5016 Support java8 date/time in date tag new c58e492 Merge pull request #330 from aleksandr-m/feature/java8_date aacac5b is described below commit aacac5b9fc0cbf4c191fcb2e8be232e3fa736dd0 Author: Aleksandr Mashchenko AuthorDate: Wed Feb 6 23:06:09 2019 +0200 WW-5016 Support java8 date/time in date tag --- .../java/org/apache/struts2/components/Date.java | 108 ++--- .../apache/struts2/views/jsp/ui/DateTagTest.java | 61 ++-- 2 files changed, 107 insertions(+), 62 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Date.java b/core/src/main/java/org/apache/struts2/components/Date.java index ba2c82d..a68e339 100644 --- a/core/src/main/java/org/apache/struts2/components/Date.java +++ b/core/src/main/java/org/apache/struts2/components/Date.java @@ -28,12 +28,15 @@ import org.apache.struts2.views.annotations.StrutsTagAttribute; import java.io.IOException; import java.io.Writer; -import java.text.DateFormat; -import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -import java.util.TimeZone; /** * @@ -220,11 +223,11 @@ public class Date extends ContextBean { * @param date the date * @return the date nicely */ -public String formatTime(TextProvider tp, java.util.Date date) { -java.util.Date now = new java.util.Date(); +public String formatTime(TextProvider tp, ZonedDateTime date) { +ZonedDateTime now = ZonedDateTime.now(); StringBuilder sb = new StringBuilder(); -List args = new ArrayList(); -long secs = Math.abs((now.getTime() - date.getTime()) / 1000); +List args = new ArrayList<>(); +long secs = Math.abs(now.toEpochSecond() - date.toEpochSecond()); long mins = secs / 60; long sec = secs % 60; int min = (int) mins % 60; @@ -267,7 +270,7 @@ public class Date extends ContextBean { args.clear(); args.add(sb.toString()); -if (date.before(now)) { +if (date.isBefore(now)) { // looks like this date is passed return tp.getText(DATETAG_PROPERTY_PAST, DATETAG_DEFAULT_PAST, args); } else { @@ -275,54 +278,55 @@ public class Date extends ContextBean { } } +@Override public boolean end(Writer writer, String body) { -String msg; -java.util.Date date = null; +ZonedDateTime date = null; +final ZoneId tz = getTimeZone(); // find the name on the valueStack -try { -//support Calendar also -Object dateObject = findValue(name); -if (dateObject instanceof java.util.Date) { -date = (java.util.Date) dateObject; -} else if (dateObject instanceof Calendar) { -date = ((Calendar) dateObject).getTime(); -} else if (dateObject instanceof Long) { -date = new java.util.Date((long) dateObject); -} else { -if (devMode) { -TextProvider tp = findProviderInStack(); -String developerNotification = ""; -if (tp != null) { -developerNotification = findProviderInStack().getText( -"devmode.notification", -"Developer Notification:\n{0}", -new String[]{ -"Expression [" + name + "] passed to tag which was evaluated to [" + dateObject + "](" -+ (dateObject != null ? dateObject.getClass() : "null") + ") isn't instance of java.util.Date nor java.util.Calendar nor long!" -} -); -} -LOG.warn(developerNotification); -} else { -LOG.debug("Expression [{}] passed to tag which was evaluated to [{}]({}) isn't instance of java.util.Date nor java.util.Calendar nor long!", -name, dateObject, (dateObject != null ? dateObject.getClass() : "null")); +Object dateObject = findValue(name); +if (dateObject instanceof java.util.Date) { +date = ((java.util.Date) dateObject).toInstant().atZone(tz); +} else if (dateObject instanceof Calendar) { +date = ((Calendar) dateObject).toInstant().atZone(tz); +} else if
[struts] branch master updated: Update jenkins badge
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/master by this push: new 1a5653a Update jenkins badge new 2a92b71 Merge pull request #331 from aleksandr-m/feature/jenkins_badge 1a5653a is described below commit 1a5653ad9bd0f45d9ee454e887f1adeff7cb8ccf Author: Aleksandr Mashchenko AuthorDate: Wed Feb 6 23:14:58 2019 +0200 Update jenkins badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c51a1c9..32877da 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The Apache Struts web framework --- -[![Build Status @ Jenkins](https://builds.apache.org/buildStatus/icon?job=Struts-master-JDK7)](https://builds.apache.org/view/S-Z/view/Struts/job/Struts-master-JDK7/) +[![Build Status @ Jenkins](https://builds.apache.org/buildStatus/icon?job=Struts-master-JDK8)](https://builds.apache.org/view/S-Z/view/Struts/job/Struts-master-JDK8/) [![Build Status @ Travis](https://travis-ci.org/apache/struts.svg?branch=master)](https://travis-ci.org/apache/struts) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/) [![Javadocs](https://javadoc.io/badge/org.apache.struts/struts2-core.svg)](https://javadoc.io/doc/org.apache.struts/struts2-core)
[struts-site] branch asf-site updated: Updates production by Jenkins
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-site by this push: new cd284cf Updates production by Jenkins cd284cf is described below commit cd284cf486be2b72df3421dc34c3aaa887af7d61 Author: jenkins AuthorDate: Thu Feb 7 06:17:35 2019 + Updates production by Jenkins --- content/core-developers/validation-annotation.html | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/content/core-developers/validation-annotation.html b/content/core-developers/validation-annotation.html index 0cba7ca..63b493e 100644 --- a/content/core-developers/validation-annotation.html +++ b/content/core-developers/validation-annotation.html @@ -149,12 +149,10 @@ is no longer necessary. An Annotated Interface - Mark the interface with @Validation() Apply standard or custom annotations at method level - @Validation() - public interface AnnotationDataAware { + public interface AnnotationDataAware { void setBarObj(Bar b); @@ -172,8 +170,7 @@ is no longer necessary. An Annotated Class - @Validation() - public class SimpleAnnotationAction extends ActionSupport { + public class SimpleAnnotationAction extends ActionSupport { @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a value for bar.") @IntRangeFieldValidator(type = ValidatorType.FIELD, min = "6", max = "10", message
[struts-site] branch master updated: Drops reference to @Validation() as not needed
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/master by this push: new 581af66 Drops reference to @Validation() as not needed 581af66 is described below commit 581af66e7859f7e0c432f1934a320a9ce30da341 Author: Lukasz Lenart AuthorDate: Thu Feb 7 07:11:41 2019 +0100 Drops reference to @Validation() as not needed --- source/core-developers/validation-annotation.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/core-developers/validation-annotation.md b/source/core-developers/validation-annotation.md index 89ab9e5..79aea0a 100644 --- a/source/core-developers/validation-annotation.md +++ b/source/core-developers/validation-annotation.md @@ -23,11 +23,9 @@ Validation annotation must be applied at Type level. ### An Annotated Interface -- Mark the interface with `@Validation()` - Apply standard or custom annotations at method level ```java - @Validation() public interface AnnotationDataAware { void setBarObj(Bar b); @@ -46,7 +44,6 @@ Validation annotation must be applied at Type level. ### An Annotated Class ```java - @Validation() public class SimpleAnnotationAction extends ActionSupport { @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a value for bar.")