[ofbiz-framework] branch trunk updated: Fixed: Unable to navigate to 'Recently approved' screen under image management

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Fixed: Unable to navigate to 'Recently approved' screen under image management

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new fb447e7  Fixed: Unable to navigate to 'Recently approved' screen under image management
fb447e7 is described below

commit fb447e7b62b12f57f4a9a97da2a934925cdb0d84
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Thu May 14 13:34:42 2020 +0200

    Fixed: Unable to navigate to 'Recently approved' screen under image management
   
    (OFBIZ-11403)
   
    It works on stable demo which uses 2.4.13 instead of 2.5.11 for trunk.
   
    I guess it's because since Groovy 2.5 DateTimeFormatter, introduced with Java 8,
    is used underneath.
   
    This fixes and improves it regarding localisation. Because it's easier with
    DateTimeFormatter and LocalDateTime to handle localisation
---
 .../imagemanagement/ImageRecentlyApproved.groovy   | 29 +++++++++++-----------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy b/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy
index 1149cc8..2975122 100644
--- a/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy
+++ b/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy
@@ -19,26 +19,27 @@
 
 import org.apache.ofbiz.base.util.*
 import org.apache.ofbiz.entity.util.*
-import java.text.SimpleDateFormat
-import java.util.List
-import java.util.Set
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
 import org.apache.ofbiz.entity.util.EntityFindOptions
 
+import java.sql.Timestamp
+import java.text.SimpleDateFormat
+import java.time.LocalDateTime
+import java.time.format.DateTimeFormatter
+import java.time.format.FormatStyle
+import java.util.List
+import java.util.Set
+
 def limit = 13 // set number of days
-def sdf = new SimpleDateFormat("EEEE yyyy-MM-dd 00:00:00.000")
-def sdf2 = new SimpleDateFormat("EEEE dd/MM/yyyy")
+def sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
+def sdf2 = DateTimeFormatter.ofPattern("EEEE dd/MM/yyyy", locale);
 def sdfTime = new SimpleDateFormat("HH:mm")
-def today = new Date()
+def today = LocalDateTime.now()
 
-for(i in 0..limit){
-    def date1 = sdf.format(today-i)
-    def date2 = sdf.format(today-i+1)
-    def parseDate1 = sdf.parse(date1)
-    def parseDate2 = sdf.parse(date2)
-    def timeStampDate1 = UtilDateTime.toTimestamp(parseDate1)
-    def timeStampDate2 = UtilDateTime.toTimestamp(parseDate2)
+for (i in 0..limit){
+    def timeStampDate1 = Timestamp.valueOf(today.minusDays(i+1).format(sdf).toString())
+    def timeStampDate2 = Timestamp.valueOf(today.minusDays(i).format(sdf).toString())
     // make condition for distinct productId
     def exprs = []
     exprs.add(EntityCondition.makeCondition("productContentTypeId",EntityOperator.EQUALS, "IMAGE"))
@@ -55,7 +56,7 @@ for(i in 0..limit){
     groupByTimeList.each() {
         key,value -> tempTimeList.add(value.purchaseFromDate)
     }
-    
+
     def time = []
     if(tempTimeList.size > 0){
         for(j in 0..tempTimeList.size-1){