package minipss.util;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.lang3.time.DateUtils;
public class DateUtil {
public static Date endOfDay(Date d) {
return DateUtils.addSeconds(
DateUtils.addDays(DateUtils.truncate(d, Calendar.DATE), 1), -1);
}
}
public class SimpleDateFormatDemo {
public static void main(String[] args) {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyy年MM月dd日HH点mm分ss秒");
String date = sdf.format(now);
System.out.println(date);
String fileString = System.getProperty("file.separator");
System.out.println(fileString);
}
package cn._520it.crm.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn._520it.crm.domain.Node;
public class TreeUtil {
public static List<Node> getTree(List<Map> depts){
Map<String,Node> tempMaps = new HashMap<String,Node>();
Node tempNode;
Map temp;
for (int i = 0; i < depts.size(); i++) {
temp = depts.get(i);
tempNode = new Node();
tempNode.setId(String.valueOf(temp.get("id")));
tempNode.setText(String.valueOf(temp.get("text")));
tempMaps.put(String.valueOf(temp.get("id")), tempNode);
}
List<Node> list = new ArrayList<Node>();
Object obj;
for (int i = 0; i < depts.size(); i++) {
temp = depts.get(i);
obj = temp.get("pid");
if(obj==null){
//没有pid,直接加入List<Node>
list.add(tempMaps.get(String.valueOf(temp.get("id"))));
}else{
//把当前的节点添加带对应父节点下就可以了
Node parentNode = tempMaps.get(String.valueOf(temp.get("pid")));
Node childNode = tempMaps.get(String.valueOf(temp.get("id")));
parentNode.getChildren().add(childNode);
}
}
return list;
}
}
package gener;
import java.io.File;
import java.io.FileWriter;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
public class XmlUtil {
public static void mergeXML(File xml, String appendingXml) throws Exception {
SAXReader reader = new SAXReader();
Document doc = reader.read(xml);
Document flagment = DocumentHelper.parseText(appendingXml);
Element flagEle = flagment.getRootElement();
flagEle.setQName(new QName(flagEle.getName(), doc.getRootElement()
.getNamespace()));
if (flagEle.elements().size() > 0) {
for (Object c : flagEle.elements()) {
Element cel = (Element) c;
cel.setQName(new QName(cel.getName(), flagEle.getNamespace()));
}
}
doc.getRootElement().add(flagEle);
XMLWriter writer = new XMLWriter(new FileWriter(xml));
writer.write(doc.getRootElement());
writer.close();
}
}