String转换为JSON以及时间的格式化
来源:互联网 发布:末世特种兵txt下载知轩 编辑:程序博客网 时间:2024/05/23 00:03
<pre name="code" class="java"><span style="font-family:Microsoft YaHei;">public Map DnsQueryThird (String ipString ){ Map map = createDwrMap(); String ADD_URL = "http://out.dns.dnion.com:53053/dnsout?domain=";// String ADD_URL = "http://interface.dns.dnion.com/getdnsip"; String parm = ""; if(ipString!=null&&ipString.trim().length()>0) parm +=ipString.trim(); else { return null; } String lines = ConnectInterfaceThird(ADD_URL,parm);//处理业务 List list = new ArrayList(); if( lines.trim().length()>0) { if(lines.indexOf("client") == -1) { map.put("NOTFOUND","1"); return map; }// String[] strings = lines.split("<h4>"); JSONObject jsonObject = JSONObject.fromObject(lines);//String转换为JSON JSONArray jsonResultsArray = jsonObject.getJSONArray("results"); String succ = jsonObject.getString("success"); for (Object resultsObj : jsonResultsArray) { JSONObject jsonResultsObj = (JSONObject) resultsObj; String dateString = jsonResultsObj.getString("date"); SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss",Locale.US);//日期是Jul英文格式,parse需要加Locale.US SimpleDateFormat sdf_CN = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); Date date = null; try { date = sdf.parse(dateString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } String dateString_CN = sdf_CN.format(date); String client = jsonResultsObj.getString("client"); Map resIPMap = queryipLib(client,0); if(resIPMap.get(EXCEPTION_MESSAGE)==null||resIPMap.get(EXCEPTION_MESSAGE).toString().trim().length()==0) { Map tempMap = new HashMap(); tempMap.put("ip", client); tempMap.put("resulttime", dateString_CN); tempMap.put("resultOwnLand", resIPMap.get("resOwnLand").toString()); tempMap.put("resultIsp", resIPMap.get("resIsp").toString()); tempMap.put("resultArea", resIPMap.get("resArea").toString()); list.add(tempMap); } } map.put("res", list) ; } else { map.put(HAVE_EXCEPTION,new Boolean(true)); } return map; }</span>
0 0
- String转换为JSON以及时间的格式化
- js 解析java后端的String为json格式并格式化Json格式的时间
- String转换为json
- java的json时间转换为年月日
- java的json时间转换为年月日
- json格式化后的日期转换为DateTime
- String转换为json对
- javascript json转换为string
- 时间戳转换为String
- 格式化json传送的时间
- 基本数据类型转换以及时间格式化
- JSON与String之间的转换以及公用类
- 时间戳格式化转换为日期格式
- c#常用的Datable转换为json,以及json转换为DataTable操作方法
- c#常用的Datable转换为json,以及json转换为DataTable操作方法
- java String 和date 转换 以及时间的比较
- json转换时间类型的字符串为object-小心
- String格式的时间转换为Date类型
- 原型图的团队设计
- Unity3D中使用Leap Motion进行手势控制
- 动手写第一个windows程序 新建一个窗口
- C++ 全局变量、局部变量、静态全局变量、静态局部变量的区别
- .msi安装包安装方法(安装错误2503和2502)
- String转换为JSON以及时间的格式化
- 在heroku上使用远程mysql Connect To Remote MySQL Database From Heroku
- 全局变量和局部变量
- Inflater
- 阿里实习生java面试
- C语言程序基础4.5
- 获得spring容器上下文
- #import和#include和@class用法
- Php基础字符串篇