[英]how to convert date to number of year in android and number of month
I want to get which day of year is it. 我想知道一年的哪一天。 a year have 365 days . 一年有365天。 I want to get which day base on the data , i have . 我想根据数据得到哪一天。 for example : my date is : 2017/01/03 ---> base on this data I found that it means day 2. 例如:我的日期是:2017/01/03 --->基于此数据,我发现这意味着第二天。
You can use Calendar class to get your desired output: 您可以使用Calendar类获得所需的输出:
Calendar cal = Calendar.getInstance(); // get calendar object instance
cal.setTime("set your time here"); // set your desired time here, it can be as Date object, if you've millis then use setTimeInMillis();
cal.get(Calendar.DAY_OF_YEAR); // get day of year like this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.