获取白天本月形式Date对象价值的Andr​​oid?白天、对象、形式、价值

2023-09-05 11:19:08 作者:⑦秒鍾の誋憶

通过使用这种code:

By Using this code :

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = format.parse(dtStart);
return date;

我已经转换字符串日期Date对象,并获取价值... ------>太阳02月17日07:00:00 GMT 2013< ---------------

I have converted the String Date by Date Object and Get the Value ... ------> Sun Feb 17 07:00:00 GMT 2013 <---------------

现在我想提取日(周日/周一),月表在这里任何帮助????

Now i want to Extract Day (Sunday /Monday ) and Month form here any help ????

推荐答案

使用简单的版本是

String dayOfTheWeek = (String) android.text.format.DateFormat.format("EEEE", date);
String month = (String) android.text.format.DateFormat.format("MMM", date);

更新了这么请求

Updated for request of SO

String dayOfTheWeek = (String) android.text.format.DateFormat.format("EEEE", date);//Thursday
String stringMonth = (String) android.text.format.DateFormat.format("MMM", date); //Jun
String intMonth = (String) android.text.format.DateFormat.format("MM", date); //06
String year = (String) android.text.format.DateFormat.format("yyyy", date); //2013
String day = (String) android.text.format.DateFormat.format("dd", date); //20