Commit 34167fae by Mikhail Gashenko

JsonNode: (draft11) added dates counter

parent cb7319e8
...@@ -20,6 +20,7 @@ import java.text.ParseException; ...@@ -20,6 +20,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.ejb.ActivationConfigProperty; import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven; import javax.ejb.MessageDriven;
import javax.naming.NameNotFoundException; import javax.naming.NameNotFoundException;
...@@ -203,7 +204,7 @@ public class Main implements MessageListener { ...@@ -203,7 +204,7 @@ public class Main implements MessageListener {
unlockRoute(); unlockRoute();
} }
} }
private void constructNewTableRow(String b2b1, String b4b1) throws Exception { private void constructNewTableRow(String b2b1, String b4b1) throws Exception {
AsNode tableNode = findNode(targetFormData, "table"); AsNode tableNode = findNode(targetFormData, "table");
if (tableNode != null) { if (tableNode != null) {
...@@ -233,6 +234,7 @@ public class Main implements MessageListener { ...@@ -233,6 +234,7 @@ public class Main implements MessageListener {
n3.setId("days-b" + tablesCounter); n3.setId("days-b" + tablesCounter);
n3.setType("textbox"); n3.setType("textbox");
n3.setLabel(" "); n3.setLabel(" ");
n3.setValue(Integer.toString(dateDiffToDays(b2b1, b4b1)));
n4.setId("matpom-b" + tablesCounter); n4.setId("matpom-b" + tablesCounter);
n4.setType("listbox"); n4.setType("listbox");
...@@ -259,6 +261,16 @@ public class Main implements MessageListener { ...@@ -259,6 +261,16 @@ public class Main implements MessageListener {
} }
} }
private int dateDiffToDays(String dateLess, String dateMore) throws ParseException {
Date dateMore_ = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateMore);
Date dateLess_ = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateLess);
long diff = dateMore_.getTime() - dateLess_.getTime();
TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
return (int) TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
}
private int appendabeTableRowsCount(List<AsNode> lan, String tableID, String tableElementID) { private int appendabeTableRowsCount(List<AsNode> lan, String tableID, String tableElementID) {
int counter = 0; int counter = 0;
for (;;) { for (;;) {
...@@ -307,7 +319,6 @@ public class Main implements MessageListener { ...@@ -307,7 +319,6 @@ public class Main implements MessageListener {
private static String dateValueFromKey (String keyValue) throws ParseException { private static String dateValueFromKey (String keyValue) throws ParseException {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(keyValue); Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(keyValue);
return new SimpleDateFormat("dd.MM.yyy").format(date); return new SimpleDateFormat("dd.MM.yyy").format(date);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment