我的响应类似{数据:{a:[{date1:“ 2018-12-23”,date2:“ 23-11-2018”},{date1:“ 2018-12-20”,date2:“ 23-11-2018“”}]}}
并想测试每个date1字段是否都小于今天的日期,并且每个date2都小于输入日期字段(我在输入有效负载中有一个日期字段)。如何执行该操作。
答案 0 :(得分:1)
在许多方面,这是其中之一。重构此代码以使其更简洁:P
class TestPallet extends Container {
TestIcon firstIcon;
TestIcon secondIcn;
TestIcon thirdIcn;
TestIcon fourIcn;
Container panel;
public TestPallet() {
super();
panel= new Container();
panel.getStyle().setBgColor(0x323232);
panel.getStyle().setBgTransparency(255);
panel.setLayout(new BoxLayout(BoxLayout.X_AXIS));
panel.getStyle().setBorder(Border.createLineBorder(2, 0xffffff));
panel.getStyle().setPadding(10, 10,10,10);
panel.getStyle().setMargin(50, 10, 10, 10);
panel.setSelectedStyle(panel.getStyle());
Container row1 = new Container();
row1.setLayout(new BoxLayout(BoxLayout.X_AXIS));
int margin = Display.getInstance().convertToPixels(1, true);
firstIcon = new ShapeIcon(1, this);
panel.addComponent(firstIcon);
secondIcn = new ShapeIcon(2, this);
panel.addComponent(secondIcn);
thirdIcn = new ShapeIcon(3, this);
panel.addComponent(thirdIcn);
fourIcn = new ShapeIcon(4, this);
panel.addComponent(fourIcn);
addComponent(panel);
}
}
class TestIcon extends Container{
boolean selected=false;
ShapePallet pallet;
int t;
public TestIcon(int s, ShapePallet sp) {
super();
pallet=sp;
t=s;
getStyle().setBgTransparency(0);
getStyle().setBgColor(0xdcdcdc);
this.setSelectedStyle(this.getStyle());
setFocusable(true);
}
@Override
public void paint(Graphics g) {
int size = Display.getInstance().convertToPixels(2, false);
Image im= null;
if(t==1) {
size *= 2;
im = DisplayManager.getWmUiBuilder().getResources().getImage("image1.png").scaled(size, size);
}
else if(t== 2) {
size *= 2;
im = DisplayManager.getWmUiBuilder().getResources().getImage("image2.png").scaled(size, size );
}
else if(t== 3) {
size *= 2;
im = DisplayManager.getWmUiBuilder().getResources().getImage("image3.png").scaled(size, size);
}
else if(t== 4) {
size *= 2;
im = DisplayManager.getWmUiBuilder().getResources().getImage("image4.png").scaled(size, size);
}
g.drawImage(im,getX() + ((getWidth() - im.getWidth())) / 2, getY() + ((getHeight() - im.getHeight()) / 2));
}
}