Commit 34167fae by Mikhail Gashenko

JsonNode: (draft11) added dates counter

parent cb7319e8
......@@ -20,6 +20,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.naming.NameNotFoundException;
......@@ -233,6 +234,7 @@ public class Main implements MessageListener {
n3.setId("days-b" + tablesCounter);
n3.setType("textbox");
n3.setLabel(" ");
n3.setValue(Integer.toString(dateDiffToDays(b2b1, b4b1)));
n4.setId("matpom-b" + tablesCounter);
n4.setType("listbox");
......@@ -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) {
int counter = 0;
for (;;) {
......@@ -307,7 +319,6 @@ public class Main implements MessageListener {
private static String dateValueFromKey (String keyValue) throws ParseException {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(keyValue);
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