繁体   English   中英

如何将日期转换为android中的年数和月数

[英]how to convert date to number of year in android and number of month

我想知道一年的哪一天。 一年有365天。 我想根据数据得到哪一天。 例如:我的日期是:2017/01/03 --->基于此数据,我发现这意味着第二天。

您可以使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM