![](/img/trans.png)
[英]Parsing date string using SimpleDateFormat with Wildcard support (e.g. *yyyy*MM*dd*hh*mm*ss)
[英]How to get date from calendarView() onCreate, with a specific format e.g. DD/MM/YYYY?
我想从日历视图中获取日期:
calendar = (CalendarView) findViewById(R.id.calendarView);
通过尝试:
String selectedDate = calendar.getDate().toString();
但我得到错误说toString()
方法无法解决我想进一步得到它的格式为“DD / MM / YYYY”
你应该使用SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String selectedDate = sdf.format(new Date(calendar.getDate()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.