【问题标题】:Parsing Json data, Android解析Json数据,Android
【发布时间】:2016-11-19 16:21:02
【问题描述】:

在我的 Json 中,我有下一个输出

......
"publish_date": "2016-07-16 08:09:41"
......

是否可以只解析/提取没有时间的日期,而不调整Json

【问题讨论】:

  • 使用子字符串可以忽略最后 8 个字符。
  • 谢谢!运行良好TextView txdate = (TextView)findViewById(R.id.date_item); getDate = getDate.substring(0, getDate.length()-8); txdate.setText(getDate);

标签: android arrays json parsing


【解决方案1】:

使用SimpleDateFormat

例子:

String s = "your parsed jsonObject" ;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(simpleDateFormat.parse(s));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 2017-01-23
    • 1970-01-01
    相关资源
    最近更新 更多