/* (non-Javadoc)
@see net.finmath.time.daycount.DayCountConventionInterface#getDaycount(org.threeten.bp.LocalDate, org.threeten.bp.LocalDate)
325034
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		return daysBetween(startDate, endDate);
	}
374628
public static double getJulianDayNumber(Calendar time) {

        if (time == null) {
            time = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
        }

        double jd = BASE_JD + time.getTimeInMillis() / MILLISEC_PER_DAY;

        return jd;
    }
145818
@Override
	public double getDaycountFraction(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycountFraction(endDate,startDate);
		}

		int periodIndexEndDate = Collections.binarySearch(periods, new Period(endDate, endDate, endDate, endDate));
		int periodIndexStartDate = Collections.binarySearch(periods, new Period(startDate, startDate, startDate, startDate));

		if(periodIndexEndDate < 0) {
			periodIndexEndDate		= -periodIndexEndDate-1;
		}
		if(periodIndexStartDate < 0) {
			periodIndexStartDate	= -periodIndexStartDate-1;
		} else {
			periodIndexStartDate	= periodIndexStartDate+1;
		}

		Period startDatePeriod = periods.get(periodIndexStartDate);
		Period endDatePeriod = periods.get(periodIndexEndDate);

		double periodFraction =
				getDaycount(startDate, startDatePeriod.getPeriodEnd()) / getDaycount(startDatePeriod.getPeriodStart(), startDatePeriod.getPeriodEnd())
				+
				getDaycount(endDatePeriod.getPeriodStart(), endDate) / getDaycount(endDatePeriod.getPeriodStart(), endDatePeriod.getPeriodEnd())
				+
				(periodIndexEndDate - periodIndexStartDate) - 1;

		return periodFraction / frequency;
	}
1361809
public static LocalDate today(EvaluationContext ctx) {
        return ctx.getNow().atZone(ctx.getTimezone()).toLocalDate();
    }
560178
public Integer getDay() {
		String dateValue = getValue();

		if (dateValue != null && dateValue.length() == DAY_END) {
			return parseDateComponent(dateValue.substring(DAY_START, DAY_END), getPaddingChar());
		} else {
			return null;
		}
	}
989802
@Override
    public DateCalculator<LocalDate> moveByDays(final int days) {
        setCurrentIncrement(days);

        setCurrentBusinessDate(getCurrentBusinessDate().plusDays(days));

        if (getHolidayHandler() != null) {
            setCurrentBusinessDate(getHolidayHandler().moveCurrentDate(this));
        }

        return this;
    }
1053361
public static Date toDate(LocalDate date)
	{
		if(date == null)
			return null;
		
		return  java.util.Date
	      .from(date.atStartOfDay(ZoneId.systemDefault())
	      .toInstant());
	}
872500
public long getCount(Date fromWhen, Date toWhen, boolean fromInclusive, boolean toInclusive) {
		return getCount(fromWhen.getTime(), toWhen.getTime(), true, false);
	}
390456
@SuppressWarnings("deprecation")
    public static LocalDate toLocalDate(java.sql.Date sqlDate) {
        return LocalDate.of(sqlDate.getYear() + 1900, sqlDate.getMonth() + 1, sqlDate.getDate());
    }
42405
private static String getDaytimeReply(
        String address,
        int port,
        int timeout
    ) throws IOException {

        IOException ioe = null;
        Socket socket = null;
        StringBuilder sb = null;

        try {

            socket = new Socket(address, port);
            socket.setSoTimeout(timeout * 1000);

            InputStream is = socket.getInputStream();
            InputStreamReader ir = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(ir);

            int len;
            char[] chars = new char[100];
            sb = new StringBuilder();

            while ((len = br.read(chars)) != -1) {
                sb.append(chars, 0, len);
            }

            is.close();
            ir.close();
            br.close();

        } catch (IOException ex) {

            ioe = ex;

        } finally {

            try {
                if (socket != null) {
                    socket.close();
                }
            } catch (IOException ex) {
                System.err.println(
                    "Ignored exception while closing time server socket: "
                    + ex.getMessage()
                );
                ex.printStackTrace(System.err);
            }

        }

        if (ioe == null) {
            return sb.toString();
        } else {
            throw ioe;
        }

    }
1115312
def _getLocalWhen(self, date_from, num_days=1):
        
        dateFrom, timeFrom = getLocalDateAndTime(date_from, self.time_from,
                                                 self.tz, dt.time.min)
        if num_days > 1 or self.time_to is not None:
            daysDelta = dt.timedelta(days=self.num_days - 1)
            dateTo, timeTo = getLocalDateAndTime(date_from + daysDelta,
                                                 self.time_to, self.tz)
        else:
            dateTo = dateFrom
            timeTo = None

        if dateFrom == dateTo:
            retval = _("{date} {atTime}").format(
                    date=dateFormat(dateFrom),
                    atTime=timeFormat(timeFrom, timeTo, gettext("at ")))
        else:
            # Friday the 10th of April for 3 days at 1pm to 10am
            localNumDays = (dateTo - dateFrom).days + 1
            retval = _("{date} for {n} days {startTime}").format(
                    date=dateFormat(dateFrom),
                    n=localNumDays,
                    startTime=timeFormat(timeFrom, prefix=gettext("starting at ")))
            retval = _("{dateAndStartTime} {finishTime}").format(
                    dateAndStartTime=retval.strip(),
                    finishTime=timeFormat(timeTo, prefix=gettext("finishing at ")))
        return retval.strip()
1264431
public static int today() {
        java.time.LocalDate today = java.time.LocalDate.now();
        return today.getYear() * 10000 + today.getMonthValue() * 100 + today.getDayOfMonth();
    }
305880
public LocalDateTime getEndAsLocalDateTime() {

        PlainTimestamp tsp = this.getEndAsTimestamp();
        return ((tsp == null) ? null : tsp.toTemporalAccessor());

    }
1036002
public function getRelativeDayCount($end = null, $locale = null, $query = null, $cacheKey = null)
    {
        if (is_null($end))
        {
            $end = Carbon::today();
        }

        return $this->getCountInBetween($end, $end->copy()->endOfDay(), $locale, $query, $cacheKey);
    }
505076
public long getCount(Date fromWhen, Date toWhen) {
		return getCount(fromWhen.getTime(), toWhen.getTime(), true, false);
	}
1114597
public LocalDate estimateFromSiblings(final LocalDate localDate) {
        if (localDate != null) {
            return localDate;
        }
        boolean beforePerson = true;
        LocalDate date = null;
        int increment = typicals.gapBetweenChildren();
        final PersonNavigator navigator = new PersonNavigator(person);
        final List<Family> families = navigator.getFamiliesC();
        for (final Family family : families) {
            for (final Person sibling : getChildren(family)) {
                if (person.equals(sibling)) {
                    beforePerson = false;
                    if (date != null) {
                        break;
                    }
                    increment = 0;
                    continue;
                }
                final String siblingString = getBirthDate(sibling);
                if (!validDateString(siblingString)) {
                    increment = incrementWhenEmptyDate(beforePerson, increment);
                    continue;
                }
                date = createLocalDate(siblingString);
                increment = incrementWhenDate(beforePerson, increment);
                if (!beforePerson) {
                    break;
                }
            }
        }

        if (date != null) {
            date = firstDayOfMonth(plusYears(date, increment));
        }
        return date;
    }
128931
public static int getDayOfWeek(@NotNull final Date date) {
		int result = getWithMondayFirst(date, Calendar.DAY_OF_WEEK);
		return result == 1 ? 7 : result - 1;
	}