gpt4 book ai didi

net.objectlab.kit.datecalc.common.WorkingWeek类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 03:39:05 27 4
gpt4 key购买 nike

本文整理了Java中net.objectlab.kit.datecalc.common.WorkingWeek类的一些代码示例,展示了WorkingWeek类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkingWeek类的具体详情如下:
包路径:net.objectlab.kit.datecalc.common.WorkingWeek
类名称:WorkingWeek

WorkingWeek介绍

[英]Immutable Working Week, default is Mon->Friday.
[中]不可变的工作周,默认为周一->周五。

代码示例

代码示例来源:origin: net.objectlab.kit.datecalc/datecalc-common

/**
 * If the value for the given day has changed, return a NEW WorkingWeek.
 * 
 * @param working
 *            true if working day
 * @param dayOfWeek
 *            e.g. Calendar.MONDAY, Calendar.TUESDAY, etc
 * @return a new instance of a <code>WorkingWeek</code> with the working
 *         day set
 */
public WorkingWeek withWorkingDayFromCalendar(final boolean working, final int dayOfWeek) {
  final int day = adjustDay(dayOfWeek);
  WorkingWeek ret = this;
  if (working && (!isWorkingDayFromCalendar(dayOfWeek))) {
    ret = new WorkingWeek((byte) (workingDays + WORKING_WEEK_DAYS_OFFSET[day]));
  } else if (!working && isWorkingDayFromCalendar(dayOfWeek)) {
    ret = new WorkingWeek((byte) (workingDays - WORKING_WEEK_DAYS_OFFSET[day]));
  }
  return ret;
}

代码示例来源:origin: Appendium/objectlabkit

/**
 * is the date a non-working day according to the WorkingWeek?
 */
public boolean isWeekend(final Calendar date) {
  assert workingWeek != null;
  return !workingWeek.isWorkingDay(date);
}

代码示例来源:origin: net.objectlab.kit/datecalc-joda

public JodaWorkingWeek(final WorkingWeek ww) {
  this(ww.getWorkingDays());
}

代码示例来源:origin: Appendium/objectlabkit

public void testSimpleForwardStartDateIdealWeekend() {
  final DateCalculator<E> cal = newDateCalculator("bla", HolidayHandlerType.MODIFIED_PRECEDING);
  Assert.assertEquals("Name", "bla", cal.getName());
  Assert.assertEquals("Holidays size", 0, cal.getHolidayCalendar().getHolidays().size());
  final WorkingWeek ww = new WorkingWeek().withWorkingDayFromCalendar(false, Calendar.MONDAY).withWorkingDayFromCalendar(true, Calendar.TUESDAY)
      .withWorkingDayFromCalendar(true, Calendar.WEDNESDAY).withWorkingDayFromCalendar(true, Calendar.THURSDAY)
      .withWorkingDayFromCalendar(true, Calendar.FRIDAY).withWorkingDayFromCalendar(false, Calendar.SATURDAY)
      .withWorkingDayFromCalendar(false, Calendar.SUNDAY);
  cal.setWorkingWeek(getWorkingWeek(ww));
  cal.setStartDate(newDate("2006-07-31")); // start date Monday
  checkDate("start date Monday", cal, "2006-07-28");
  cal.setStartDate(newDate("2006-08-01")); // start date Tuesday
  checkDate("start date Tuesday", cal, "2006-08-01");
  cal.setStartDate(newDate("2006-08-02")); // start date Wednesday
  checkDate("start date Wednesday", cal, "2006-08-02");
  cal.setStartDate(newDate("2006-08-03")); // start date Thursday
  checkDate("start date Thursday", cal, "2006-08-03");
  cal.setStartDate(newDate("2006-08-04")); // set on a Friday
  checkDate("start date friday", cal, "2006-08-04");
  cal.setStartDate(newDate("2006-08-05")); // set on a Saturday
  checkDate("start date Saturday", cal, "2006-08-04");
  cal.setStartDate(newDate("2006-08-06")); // set on a Sunday
  checkDate("start date Sunday", cal, "2006-08-04");
}

代码示例来源:origin: Appendium/objectlabkit

public void testSetWorkingDayFromCalendar() {
  WorkingWeek ww = new WorkingWeek();
  ww = ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday
  // working day
  ww = ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday
  // working day
  // do it twice
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertTrue("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
  ww = ww.withWorkingDayFromCalendar(false, Calendar.SUNDAY); // sunday
  // working day
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
  ww = ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday
  // working day
  // do it twice
}

代码示例来源:origin: Appendium/objectlabkit

public void testIsWorkingDayFromCalendar() {
  final WorkingWeek ww = new WorkingWeek();
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
}

代码示例来源:origin: Appendium/objectlabkit

public void testIsWorkingDay() {
  final WorkingWeek ww = new WorkingWeek();
  final Calendar cal = Calendar.getInstance();
  cal.set(Calendar.DAY_OF_MONTH, 1);
  cal.set(Calendar.MONTH, Calendar.AUGUST);
  cal.set(Calendar.YEAR, 2006);
  Date date = cal.getTime();
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDay(date));
  cal.add(Calendar.DATE, 1);
  date = cal.getTime();
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDay(date));
}

代码示例来源:origin: Appendium/objectlabkit

public void testIntersection() {
    final WorkingWeek w1 = WorkingWeek.DEFAULT;
    final WorkingWeek w2 = WorkingWeek.ARABIC_WEEK;
    final WorkingWeek w3 = w1.intersection(w2);
    // working day
    Assert.assertTrue("Calendar.MONDAY", w3.isWorkingDayFromCalendar(Calendar.MONDAY));
    Assert.assertTrue("Calendar.TUESDAY", w3.isWorkingDayFromCalendar(Calendar.TUESDAY));
    Assert.assertTrue("Calendar.WEDNESDAY", w3.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
    Assert.assertTrue("Calendar.THURSDAY", w3.isWorkingDayFromCalendar(Calendar.THURSDAY));
    Assert.assertFalse("Calendar.FRIDAY", w3.isWorkingDayFromCalendar(Calendar.FRIDAY));
    Assert.assertFalse("Calendar.SATURDAY", w3.isWorkingDayFromCalendar(Calendar.SATURDAY));
    Assert.assertFalse("Calendar.SUNDAY", w3.isWorkingDayFromCalendar(Calendar.SUNDAY));
  }
}

代码示例来源:origin: Appendium/objectlabkit

/**
 * Return a new JodaWorkingWeek if the status for the given day has changed.
 *
 * @param working
 *            true if working day
 * @param givenDayOfWeek
 *            e.g. DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, etc
 */
public Jdk8WorkingWeek withWorkingDayFromDateTimeConstant(final boolean working, final DayOfWeek givenDayOfWeek) {
  final int dayOfWeek = jdk8ToCalendarDayConstant(givenDayOfWeek);
  return new Jdk8WorkingWeek(super.withWorkingDayFromCalendar(working, dayOfWeek));
}

代码示例来源:origin: Appendium/objectlabkit

public boolean isWorkingDay(final Calendar cal) {
  return isWorkingDayFromCalendar(cal.get(Calendar.DAY_OF_WEEK));
}

代码示例来源:origin: Appendium/objectlabkit

/**
 * Create a new calendar with the intersection of WORKING days.
 * e.g. if normal and arabic calendars are intersected, the week is 3 days: Fri-Sun.
 * @param ww
 * @return a new Working week
 * @since 1.4.0
 */
public WorkingWeek intersection(final WorkingWeek ww) {
  final byte combined = (byte) (this.workingDays & ww.workingDays);
  return new WorkingWeek(combined);
}

代码示例来源:origin: Appendium/objectlabkit

public boolean isWorkingDayFromCalendar(final int dayOfWeek) {
  final int day = adjustDay(dayOfWeek);
  return (WORKING_WEEK_DAYS_OFFSET[day] & workingDays) != 0;
}

代码示例来源:origin: Appendium/objectlabkit

public DefaultCurrencyCalculatorConfig() {
  super();
  final Set<String> subjectToUsd = new HashSet<>();
  subjectToUsd.add("MXN");
  subjectToUsd.add("CLP");
  subjectToUsd.add("ARS");
  currenciesSubjectToCrossCcyForT1.put(CalculatorConstants.USD_CODE, subjectToUsd);
  workingWeeks.put("AED", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("BHD", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("EGP", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("KWD", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("OMR", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("QAR", WorkingWeek.ARABIC_WEEK);
  workingWeeks.put("SAR", WorkingWeek.ARABIC_WEEK.intersection(WorkingWeek.DEFAULT));
  workingWeeks.put("JOD", WorkingWeek.ARABIC_WEEK.intersection(WorkingWeek.DEFAULT));
}

代码示例来源:origin: Appendium/objectlabkit

public void testSimpleForwardStartDateIdealWeekend() {
  final DateCalculator<E> cal = newDateCalculator("bla", HolidayHandlerType.FORWARD);
  Assert.assertEquals("Name", "bla", cal.getName());
  Assert.assertEquals("Holidays size", 0, cal.getHolidayCalendar().getHolidays().size());
  final WorkingWeek ww = new WorkingWeek().withWorkingDayFromCalendar(false, Calendar.MONDAY).withWorkingDayFromCalendar(true, Calendar.TUESDAY)
      .withWorkingDayFromCalendar(true, Calendar.WEDNESDAY).withWorkingDayFromCalendar(true, Calendar.THURSDAY)
      .withWorkingDayFromCalendar(true, Calendar.FRIDAY).withWorkingDayFromCalendar(false, Calendar.SATURDAY)
      .withWorkingDayFromCalendar(false, Calendar.SUNDAY);
  cal.setWorkingWeek(getWorkingWeek(ww));
  cal.setStartDate(newDate("2006-07-31")); // start date Monday
  checkDate("start date Monday", cal, "2006-08-01");
  cal.setStartDate(newDate("2006-08-01")); // start date Tuesday
  checkDate("start date Tuesday", cal, "2006-08-01");
  cal.setStartDate(newDate("2006-08-02")); // start date Wednesday
  checkDate("start date Wednesday", cal, "2006-08-02");
  cal.setStartDate(newDate("2006-08-03")); // start date Thursday
  checkDate("start date Thursday", cal, "2006-08-03");
  cal.setStartDate(newDate("2006-08-04")); // set on a Friday
  checkDate("start date friday", cal, "2006-08-04");
  cal.setStartDate(newDate("2006-08-05")); // set on a Saturday
  checkDate("start date Saturday", cal, "2006-08-08");
  cal.setStartDate(newDate("2006-08-06")); // set on a Sunday
  checkDate("start date Sunday", cal, "2006-08-08");
}

代码示例来源:origin: Appendium/objectlabkit

public void testSetWorkingDayFromCalendar() {
  final WorkingWeek ww = new WorkingWeek();
  ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday
  ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
  ww.withWorkingDayFromCalendar(false, Calendar.SUNDAY); // sunday
  Assert.assertTrue("2/ Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("2/ Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("2/ Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("2/ Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("2/ Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("2/ Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertFalse("2/ Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
  ww.withWorkingDayFromCalendar(true, Calendar.SUNDAY); // sunday

代码示例来源:origin: Appendium/objectlabkit

public void testIsWorkingDayFromCalendar() {
  final WorkingWeek ww = new WorkingWeek();
  Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDayFromCalendar(Calendar.MONDAY));
  Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDayFromCalendar(Calendar.TUESDAY));
  Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDayFromCalendar(Calendar.WEDNESDAY));
  Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDayFromCalendar(Calendar.THURSDAY));
  Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDayFromCalendar(Calendar.FRIDAY));
  Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDayFromCalendar(Calendar.SATURDAY));
  Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDayFromCalendar(Calendar.SUNDAY));
}

代码示例来源:origin: net.objectlab.kit/datecalc-joda

/**
 * Return a new JodaWorkingWeek if the status for the given day has changed.
 *
 * @param working
 *            true if working day
 * @param givenDayOfWeek
 *            e.g. DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY, etc
 */
public JodaWorkingWeek withWorkingDayFromDateTimeConstant(final boolean working, final int givenDayOfWeek) {
  final int dayOfWeek = jodaToCalendarDayConstant(givenDayOfWeek);
  return new JodaWorkingWeek(super.withWorkingDayFromCalendar(working, dayOfWeek));
}

代码示例来源:origin: net.objectlab.kit.datecalc/datecalc-common

public boolean isWorkingDay(final Calendar cal) {
  return isWorkingDayFromCalendar(cal.get(Calendar.DAY_OF_WEEK));
}

代码示例来源:origin: net.objectlab.kit.datecalc/datecalc-common

public boolean isWorkingDayFromCalendar(final int dayOfWeek) {
  final int day = adjustDay(dayOfWeek);
  return (WORKING_WEEK_DAYS_OFFSET[day] & workingDays) != 0;
}

代码示例来源:origin: Appendium/objectlabkit

public void testSimpleForwardStartDateIdealWeekend() {
  final DateCalculator<E> cal = newDateCalculator("bla", HolidayHandlerType.MODIFIED_FOLLOWING);
  Assert.assertEquals("Name", "bla", cal.getName());
  Assert.assertEquals("Holidays size", 0, cal.getHolidayCalendar().getHolidays().size());
  final WorkingWeek ww = new WorkingWeek().withWorkingDayFromCalendar(false, Calendar.MONDAY).withWorkingDayFromCalendar(true, Calendar.TUESDAY)
      .withWorkingDayFromCalendar(true, Calendar.WEDNESDAY).withWorkingDayFromCalendar(true, Calendar.THURSDAY)
      .withWorkingDayFromCalendar(true, Calendar.FRIDAY).withWorkingDayFromCalendar(false, Calendar.SATURDAY)
      .withWorkingDayFromCalendar(false, Calendar.SUNDAY);
  cal.setWorkingWeek(getWorkingWeek(ww));
  cal.setStartDate(newDate("2006-07-31")); // start date Monday
  checkDate("start date Monday", cal, "2006-07-28");
  cal.setStartDate(newDate("2006-08-01")); // start date Tuesday
  checkDate("start date Tuesday", cal, "2006-08-01");
  cal.setStartDate(newDate("2006-08-02")); // start date Wednesday
  checkDate("start date Wednesday", cal, "2006-08-02");
  cal.setStartDate(newDate("2006-08-03")); // start date Thursday
  checkDate("start date Thursday", cal, "2006-08-03");
  cal.setStartDate(newDate("2006-08-04")); // set on a Friday
  checkDate("start date friday", cal, "2006-08-04");
  cal.setStartDate(newDate("2006-08-05")); // set on a Saturday
  checkDate("start date Saturday", cal, "2006-08-08");
  cal.setStartDate(newDate("2006-08-06")); // set on a Sunday
  checkDate("start date Sunday", cal, "2006-08-08");
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com