java get week of year for given a date

tl;dr For a year-week defined by the ISO 8601 standard as starting on a Monday and first week contains the first Thursday of the calendar year, use the YearWeek class from the ThreeTen-Extra library that adds functionality to the java.time classes built into Java. org.threeten.extra.YearWeek .from( LocalDate.of( 2012 , Month.APRIL , 23 ) ) .toString() … Read more

How to use java.time.ZonedDateTime / LocalDateTime in p:calendar

Your concrete problem is that you migrated from Joda’s zoneless date time instance DateTime to Java8’s zoned date time instance ZonedDateTime instead of Java8’s zoneless date time instance LocalDateTime. Using ZonedDateTime (or OffsetDateTime) instead of LocalDateTime requires at least 2 additional changes: Do not force a time zone (offset) during date time conversion. Instead, the … Read more

Retrieve current week’s Monday’s date

I would strongly recommend using Joda Time instead (for all your date/time work, not just this): // TODO: Consider time zones, calendars etc LocalDate now = new LocalDate(); LocalDate monday = now.withDayOfWeek(DateTimeConstants.MONDAY); System.out.println(monday); Note that as you’ve used Monday here, which is the first day of the week in Joda Time, this will always return … Read more

.NET: Get all Outlook calendar items

I’ve studied the docs and this is my result: I’ve put a time limit of one month hard-coded, but this is just an example. public void GetAllCalendarItems() { Microsoft.Office.Interop.Outlook.Application oApp = null; Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; oApp = new Microsoft.Office.Interop.Outlook.Application(); mapiNamespace = oApp.GetNamespace(“MAPI”); ; CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); … Read more

Create trading holiday calendar with Pandas

Perhaps it is more straightforward to create the trade calendar from scratch, like so: import datetime as dt from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, nearest_workday, \ USMartinLutherKingJr, USPresidentsDay, GoodFriday, USMemorialDay, \ USLaborDay, USThanksgivingDay class USTradingCalendar(AbstractHolidayCalendar): rules = [ Holiday(‘NewYearsDay’, month=1, day=1, observance=nearest_workday), USMartinLutherKingJr, USPresidentsDay, GoodFriday, USMemorialDay, Holiday(‘USIndependenceDay’, month=7, day=4, observance=nearest_workday), USLaborDay, USThanksgivingDay, Holiday(‘Christmas’, month=12, day=25, observance=nearest_workday) … Read more