【发布时间】:2020-05-25 18:37:21
【问题描述】:
是这样写的,我想改一下写法。我希望它在 3 月 27 日星期五用土耳其语编写。当我更改 SimpleDateFormat 中的拼写时返回 null。我正在打印从数据库中提取的数据。
我想要的输出是: Cuma Mar 27(Turkish)
数据库输出:
date ":" 2019-11-27 14: 42: 23.000000 "," timezone_type ": 3," timezone ":" UTC "
Android 输出:
Fri Mar 27 14:42:23 GMT+03:00 2020
代码:
JSONObject form_tarih2 = jObj.getJSONObject("form_tarih2");
String date = form_tarih2.getString("date");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
java.util.Locale.getDefault());
Date calculateDate = sdf.parse(date);
tarihstring = calculateDate;
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
calendar.setTime(sdf.parse(String.valueOf(tarihstring)));
calendar.add(Calendar.MONTH,4);
Date future = calendar.getTime();
【问题讨论】:
-
你能告诉我你想要的输入日期和想要的输出吗?
-
我更新了话题
-
你能告诉我这是什么Çar Kas 27吗?我得到这个输出
-
要再增加 4 个月吗?
-
顺便考虑扔掉长期过时且臭名昭著的麻烦
SimpleDateFormat和朋友,并将ThreeTenABP添加到您的Android项目中,以便使用java.time,现代Java日期和时间API .使用起来感觉好多了。
标签: java android simpledateformat