private long MsFromMonday(long currentTime) { // This methods was converted from JAVA, [currentTime] parameter should represent milliseconds since JAVA epoch: /* * Gets the milliseconds of the datetime instant from the Java epoch * of 1970-01-01T00:00:00Z. * * @return the number of milliseconds since 1970-01-01T00:00:00Z * public long getMillis() { * return iMillis; } */ // As such, a new method was created to construct a corresponding .NET datetime from the parameter received: // DateTime dateTime = new DateTime(currentTime); DateTime dateTime = Statics.CreateDateFromJavaMilliseconds(currentTime); // Created extension to Get the Week day of a given date: //DateTime mondayThisWeek = dateTime.withDayOfWeek(DateTimeConstants.MONDAY); // thus we get date of a Monday DateTime mondayThisWeek = dateTime.GetWeekDay(DayOfWeek.Monday); // thus we get date of a Monday /* This line is not needed since GetWeekDay returns date with time component set to zero. * Since calculations are done in UTC timezone the timezone following assumption is not taken to account: * - [some time zones when Daylight Savings Time starts, there is no midnight because time jumps from 11:59 to 01:00*/ // mondayThisWeek = mondayThisWeek.withTimeAtStartOfDay(); // to come to the very beginning of the Monday // Created extension GetJavaMillis //return currentTime - mondayThisWeek.getMillis(); return(currentTime - mondayThisWeek.GetJavaMillis()); }