# How to extract WEEK\_OF\_YEAR from java.util.date?

**URL:** <https://forum.inductiveautomation.com/t/how-to-extract-week-of-year-from-java-util-date/50310>\
**Category:** Ignition\
**Tags:** ignition80, scripting, vision\
**Created:** [August 26, 2021, 5:26am UTC](https://forum.inductiveautomation.com/t/how-to-extract-week-of-year-from-java-util-date/50310 "2021-08-26T05:26:26Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 26, 2021, 1:04pm UTC](https://forum.inductiveautomation.com/t/how-to-extract-week-of-year-from-java-util-date/50310/13 "2021-08-26T13:04:41Z")

</div>

java.time was added to overcome the inconsistency of Calendar.

```python
from java.time import ZoneId
from java.time.temporal import IsoFields

now = system.date.now()

date = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()

week = date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)

print now
print date
print week

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/28df2f5e826de1d4308176d851431c30565d2ae9.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-extract-week-of-year-from-java-util-date/50310)._
