Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright 2014-2015 the original author or authors.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
   * either express or implied. See the License for the specific language
   * governing permissions and limitations under the License.
   */
  package org.dbflute.cbean.coption;
  
  import java.util.Date;
  import java.util.List;
  
The option of from-to scope for Date type.
 e.g. from:{2007/04/10 08:24:53} to:{2007/04/16 14:36:29}
 
 [Comparison Pattern]
   new FromToOption().compareAsYear();
     --> column >= '2007/01/01 00:00:00'
     and column < '2008/01/01 00:00:00'
 
   new FromToOption().compareAsMonth();
     --> column >= '2007/04/01 00:00:00'
     and column < '2007/05/01 00:00:00'
 
   new FromToOption().compareAsDate();
     --> column >= '2007/04/10 00:00:00'
     and column < '2007/04/17 00:00:00'
 
   new FromToOption().compareAsHour();
     --> column >= '2007/04/10 08:00:00'
     and column < '2007/04/16 15:00:00'
 
   new FromToOption().compareAsWeek().beginWeek_DayOfWeek1st_Sunday(); 
     --> column >= '2007/04/08 00:00:00'
     and column < '2008/04/22 00:00:00'
 
   new FromToOption().compareAsQuarterOfYear(); 
     --> column >= '2007/04/01 00:00:00'
     and column < '2007/07/01 00:00:00'
 
 [Manual Adjustment]
   new FromToOption().greaterThan(); 
     --> column > '2007/04/10 08:24:53'
     and column <= '2007/04/16 14:36:29'
 
   new FromToOption().lessThan(); 
     --> column >= '2007/04/10 08:24:53'
     and column < '2007/04/16 14:36:29'
 
   new FromToOption().greaterThan().lessThan(); 
     --> column > '2007/04/10 08:24:53'
     and column < '2007/04/16 14:36:29'
 
   and so on...
 
 [Default]
   new FromToOption(); 
     --> column >= '2007/04/10 08:24:53'
     and column <= '2007/04/16 14:36:29'
 

Author(s):
jflute
  
  public class FromToOption implements ConditionOption {
  
      // ===================================================================================
      //                                                                           Attribute
      //                                                                           =========
      protected boolean _greaterThan;
      protected boolean _lessThan;
  
      protected boolean _fromPatternYearJust;
      protected boolean _fromPatternMonthJust;
      protected boolean _fromPatternDayJust;
      protected boolean _fromPatternHourJust;
     protected boolean _fromPatternWeekJust;
     protected boolean _fromPatternQuarterOfYearJust;
     protected boolean _fromDateWithNoon;
     protected Integer _fromDateWithHour;
 
     protected boolean _toPatternNextYearJust;
     protected boolean _toPatternNextMonthJust;
     protected boolean _toPatternNextDayJust;
     protected boolean _toPatternNextHourJust;
     protected boolean _toPatternNextWeekJust;
     protected boolean _toPatternNextQuarterOfYearJust;
     protected boolean _toDateWithNoon;
     protected Integer _toDateWithHour;
 
     protected Integer _yearBeginMonth = 1; // as default
     protected Integer _monthBeginDay = 1; // as default
     protected Integer _dayBeginHour = 0; // as default
     protected Integer _weekBeginDay = .// as default
     protected Integer _moveToScope;
     protected boolean _usePattern;
     protected boolean _orIsNull;

    
Does it allow one-side only from-to?
 
     protected boolean _oneSideAllowed;

    
The time-zone for filtering. (NullAllowed: if null, default zone)
 
     protected TimeZone _timeZone;
 
     // ===================================================================================
     //                                                                  Comparison Pattern
     //                                                                  ==================
     
Compare as year.
The year part of the date is only used. This method ignores operand adjustments and other patterns.
 e.g. from:{2007/04/10 08:24:53} to:{2008/08/16 14:36:29}
 
   new FromToOption().compareAsYear();
     --> column >= '2007/01/01 00:00:00'
     and column < '2009/01/01 00:00:00'
 
   new FromToOption().compareAsYear().beginYear_Month(4);
     --> column >= '2007/04/01 00:00:00'
     and column < '2009/04/01 00:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsYear() {
         fromPatternYearJust();
         toPatternNextYearJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }

    
Compare as month.
The year and month parts of the date are only used.
This method ignores operand adjustments and other patterns.
 e.g. from:{2007/04/10 08:24:53} to:{2008/08/16 14:36:29}
 
   new FromToOption().compareAsMonth();
     --> column >= '2007/04/01 00:00:00'
     and column < '2008/09/01 00:00:00'
 
   new FromToOption().compareAsMonth().beginMonth_Day(3);
     --> column >= '2007/04/03 00:00:00'
     and column < '2008/09/03 00:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsMonth() {
         fromPatternMonthJust();
         toPatternNextMonthJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }

    
Compare as date.
The year, month, day parts of the date are only used.
This method ignores operand adjustments and other patterns.
 e.g. from:{2007/04/10 08:24:53} to:{2007/04/16 14:36:29}
 
   new FromToOption().compareAsDate();
     --> column >= '2007/04/10 00:00:00'
     and column < '2007/04/17 00:00:00'
 
   new FromToOption().compareAsDate().beginDay_Hour(6);
     --> column >= '2007/04/10 06:00:00'
     and column < '2007/04/17 06:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsDate() {
         fromPatternDayJust();
         toPatternNextDayJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }

    
Compare as hour.
The year, month, day, hour parts of the date are only used.
This method ignores operand adjustments and other patterns.
 e.g. from:{2007/04/10 08:24:53} to:{2007/04/16 14:36:29}
 
   new FromToOption().compareAsHour();
     --> column >= '2007/04/10 08:00:00'
     and column < '2007/04/16 15:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsHour() {
         fromPatternHourJust();
         toPatternNextHourJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }

    
Compare as week.
The year, month, day parts of the date are only used.
This method ignores operand adjustments and other patterns.
The default beginning day of week is Sunday, but you can change it by beginWeek_DayOfWeek...() methods.
 e.g. from:{2007/04/10 08:24:53} to:{2007/04/16 14:36:29}
 
   new FromToOption().compareAsWeek().beginWeek_DayOfWeek1st_Sunday();
     --> column >= '2007/04/08 00:00:00'
     and column < '2007/04/22 00:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsWeek() {
         fromPatternWeekJust();
         toPatternNextWeekJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }

    
Compare as quarter of year.
The year and month parts of the date are only used.
This method ignores operand adjustments and other patterns.
The default beginning of quarter of year is 1st month, but you can change it by beginYear_Month...() methods.
 e.g. from:{2007/04/10 08:24:53} to:{2008/08/16 14:36:29}
 
   new FromToOption().compareAsQuarterOfYear();
     --> column >= '2007/04/01 00:00:00'
     and column < '2008/10/01 00:00:00'
 

Returns:
this. (NotNull)
 
     public FromToOption compareAsQuarterOfYear() {
         fromPatternQuarterOfYearJust();
         clearOperand();
         lessThan();
          = true;
         return this;
     }
 
     public boolean isUsePattern() { // basically for framework
         return ;
     }
 
     // -----------------------------------------------------
     //                                            Begin Year
     //                                            ----------
     
Begin year from the specified month.
The date of argument is used as only the month part.
 e.g. beginYear_Month(toLocalDate("2001/04/01"))
  year is from 4th month to 3rd month of next year
  (the 2011 year means 2011/04/01 to 2012/03/31)
 
 e.g. option.compareAsYear().beginYear_Month(toLocalDate("2001/04/01"))
  if from-date is 2011/01/01 and to-date is 2012/01/01 (means 2011, 2012 year are target),
  the condition is: greater-equal 2011/04/01 and less-than 2013/04/04
 

Parameters:
yearBeginMonth The local date that has the month of year-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month(LocalDate yearBeginMonth) { // #date_parade
         return doBeginYear_Month(toDate(yearBeginMonth));
     }

    
Begin year from the specified month.
The date of argument is used as only the month part.
 e.g. beginYear_Month(toLocalDateTime("2001/04/01"))
  year is from 4th month to 3rd month of next year
  (the 2011 year means 2011/04/01 to 2012/03/31)
 
 e.g. option.compareAsYear().beginYear_Month(toLocalDateTime("2001/04/01"))
  if from-date is 2011/01/01 and to-date is 2012/01/01 (means 2011, 2012 year are target),
  the condition is: greater-equal 2011/04/01 and less-than 2013/04/04
 

Parameters:
yearBeginMonth The local date-time that has the month of year-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month(LocalDateTime yearBeginMonth) {
         return doBeginYear_Month(toDate(yearBeginMonth));
     }

    
Begin year from the specified month.
The date of argument is used as only the month part.
 e.g. beginYear_Month(toDate("2001/04/01"))
  year is from 4th month to 3rd month of next year
  (the 2011 year means 2011/04/01 to 2012/03/31)
 
 e.g. option.compareAsYear().beginYear_Month(toDate("2001/04/01"))
  if from-date is 2011/01/01 and to-date is 2012/01/01 (means 2011, 2012 year are target),
  the condition is: greater-equal 2011/04/01 and less-than 2013/04/04
 

Parameters:
yearBeginMonth The date that has the month of year-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month(Date yearBeginMonth) {
         return doBeginYear_Month(yearBeginMonth);
     }
 
     protected FromToOption doBeginYear_Month(Date yearBeginMonth) {
         assertPatternOptionValid("beginYear_Month");
         assertArgumentNotNull("yearBeginMonth"yearBeginMonth);
          = toHandyDate(yearBeginMonth).getMonthAsOneOrigin();
         return this;
     }

    
Begin year from the specified month.
 e.g. beginYear_Month(4)
  year is from 4th month to 3rd month of next year
  (the 2011 year means 2011/04/01 to 2012/03/31)
 
 e.g. option.compareAsYear().beginYear_Month(4)
  if from-date is 2011/01/01 and to-date is 2012/01/01 (means 2011, 2012 year are target),
  the condition is: greater-equal 2011/04/01 and less-than 2013/04/04
 

Parameters:
yearBeginMonth The month for year-begin. (NotMinus, 1-12)
Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month(int yearBeginMonth) {
         assertPatternOptionValid("beginYear_Month");
         assertNotMinusNotOver("yearBeginMonth"yearBeginMonth, 12);
          = yearBeginMonth;
         return this;
     }

    
Begin year from January (1st month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month01_January");
          = 1;
         return this;
     }

    
Begin year from February (2nd month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month02_February");
          = 2;
         return this;
     }

    
Begin year from March (3rd month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month03_March");
          = 3;
         return this;
     }

    
Begin year from April (4th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month04_April");
          = 4;
         return this;
     }

    
Begin year from May (5th month).

Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month05_May() {
         assertPatternOptionValid("beginYear_Month05_May");
          = 5;
         return this;
     }

    
Begin year from June (6th month).

Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month06_June() {
         assertPatternOptionValid("beginYear_Month06_June");
          = 6;
         return this;
     }

    
Begin year from July (7th month).

Returns:
this. (NotNull)
 
     public FromToOption beginYear_Month07_July() {
         assertPatternOptionValid("beginYear_Month07_July");
          = 7;
         return this;
     }

    
Begin year from August (8th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month08_August");
          = 8;
         return this;
     }

    
Begin year from September (9th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month09_September");
          = 9;
         return this;
     }

    
Begin year from October (10th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month10_October");
          = 10;
         return this;
     }

    
Begin year from November (11th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month11_November");
          = 11;
         return this;
     }

    
Begin year from December (12th month).

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginYear_Month12_December");
          = 12;
         return this;
     }

    
Begin year from the specified month of previous year.
 e.g. beginYear_PreviousMonth(11)
  year is from 11th month of previous year to 10th month of this year
  (the 2011 year means 2010/11/01 to 2011/10/31)
 
 e.g. option.compareAsYear().beginYear_PreviousMonth(11)
  if from-date is 2011/01/01 and to-date is 2012/01/01 (means 2011, 2012 year are target),
  the condition is: greater-equal 2010/11/01 and less-than 2012/11/01
 

Parameters:
yearBeginMonth The month of previous year for year-begin. (NotMinus, 1-12)
Returns:
this. (NotNull)
 
     public FromToOption beginYear_PreviousMonth(int yearBeginMonth) {
         assertPatternOptionValid("beginYear_PreviousMonth");
         assertNotMinusNotOver("yearBeginMonth"yearBeginMonth, 12);
          = -yearBeginMonth// to be minus
         return this;
     }
 
     // -----------------------------------------------------
     //                                           Begin Month
     //                                           -----------
     
Begin month from the specified day.
The date of argument is used as only the day part.
 e.g. beginMonth_Day(toLocalDate("2001/01/03"))
  month is from 3 day to 2 day of next month
  (the 2011/11 means 2011/11/03 to 2011/12/02)
 
 e.g. option.compareAsMonth().beginMonth_Day(toLocalDate("2001/01/03"))
  if from-date is 2011/11/01 and to-date is 2011/12/01 (means 11th, 12th months are target),
  the condition is: greater-equal 2011/11/03 and less-than 2012/01/03
 

Parameters:
monthBeginDay The local date that has the day of month-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginMonth_Day(LocalDate monthBeginDay) {
         return doBeginMonth_Day(toDate(monthBeginDay));
     }

    
Begin month from the specified day.
The date of argument is used as only the day part.
 e.g. beginMonth_Day(toLocalDateTime("2001/01/03"))
  month is from 3 day to 2 day of next month
  (the 2011/11 means 2011/11/03 to 2011/12/02)
 
 e.g. option.compareAsMonth().beginMonth_Day(toLocalDateTime("2001/01/03"))
  if from-date is 2011/11/01 and to-date is 2011/12/01 (means 11th, 12th months are target),
  the condition is: greater-equal 2011/11/03 and less-than 2012/01/03
 

Parameters:
monthBeginDay The local date-time that has the day of month-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginMonth_Day(LocalDateTime monthBeginDay) {
         return doBeginMonth_Day(toDate(monthBeginDay));
     }

    
Begin month from the specified day.
The date of argument is used as only the day part.
 e.g. beginMonth_Day(toDate("2001/01/03"))
  month is from 3 day to 2 day of next month
  (the 2011/11 means 2011/11/03 to 2011/12/02)
 
 e.g. option.compareAsMonth().beginMonth_Day(toDate("2001/01/03"))
  if from-date is 2011/11/01 and to-date is 2011/12/01 (means 11th, 12th months are target),
  the condition is: greater-equal 2011/11/03 and less-than 2012/01/03
 

Parameters:
monthBeginDay The date that has the day of month-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginMonth_Day(Date monthBeginDay) {
         return doBeginMonth_Day(monthBeginDay);
     }
 
     protected FromToOption doBeginMonth_Day(Date monthBeginDay) {
         assertPatternOptionValid("beginMonth_Day");
         assertArgumentNotNull("monthBeginDay"monthBeginDay);
          = toHandyDate(monthBeginDay).getDay();
         return this;
     }

    
Begin month from the specified day.
 e.g. beginMonth_Day(3)
  month is from 3 day to 2 day of next month
  (the 2011/11 means 2011/11/03 to 2011/12/02)
 
 e.g. option.compareAsMonth().beginMonth_Day(3)
  if from-date is 2011/11/01 and to-date is 2011/12/01 (means 11th, 12th months are target),
  the condition is: greater-equal 2011/11/03 and less-than 2012/01/03
 

Parameters:
monthBeginDay The day for month-begin. (NotMinus, 1-31)
Returns:
this. (NotNull)
 
     public FromToOption beginMonth_Day(int monthBeginDay) {
         assertPatternOptionValid("beginMonth_Day");
         assertNotMinusNotOver("monthBeginDay"monthBeginDay, 31);
          = monthBeginDay;
         return this;
     }

    
Begin year from the specified day of previous month.
 e.g. beginMonth_PreviousDay(25)
  month is from 25 day of previous year to 24 day of this month
  (the 2011/11 means 2011/10/25 to 2011/11/24)
 
 e.g. option.compareAsMonth().beginMonth_PreviousDay(25)
  if from-date is 2011/11/01 and to-date is 2011/12/01 (means 11th, 12th months are target),
  the condition is: greater-equal 2011/10/25 and less-than 2011/12/25
 

Parameters:
monthBeginDay The day of previous month for month-begin. (NotMinus, 1-31)
Returns:
this. (NotNull)
 
     public FromToOption beginMonth_PreviousDay(int monthBeginDay) {
         assertPatternOptionValid("beginMonth_PreviousDay");
         assertNotMinusNotOver("monthBeginDay"monthBeginDay, 31);
          = -monthBeginDay// to be minus
         return this;
     }
 
     // -----------------------------------------------------
     //                                             Begin Day
     //                                             ---------
     
Begin day from the specified hour.
 e.g. beginDay_Hour(toLocalDate("2001/01/01 06:00:00"))
  day is from 06h to 05h of next day
  (the 2011/11/27 means 2011/11/27 06h to 2011/11/28 05h)
 
 e.g. option.compareAsDate().beginDay_Hour(toLocalDate("2001/01/01 06:00:00"))
  if from-date is 2011/11/27 and to-date is 2011/11/28 (means 27, 28 days are target),
  the condition is: greater-equal 2011/11/27 06:00:00 and less-than 2011/11/28 06:00:00
 

Parameters:
dayBeginHour The local date that has the hour of day-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginDay_Hour(LocalDate dayBeginHour) {
         return doBeginDay_Hour(toDate(dayBeginHour));
     }

    
Begin day from the specified hour.
 e.g. beginDay_Hour(toLocalDateTime("2001/01/01 06:00:00"))
  day is from 06h to 05h of next day
  (the 2011/11/27 means 2011/11/27 06h to 2011/11/28 05h)
 
 e.g. option.compareAsDate().beginDay_Hour(toLocalDateTime("2001/01/01 06:00:00"))
  if from-date is 2011/11/27 and to-date is 2011/11/28 (means 27, 28 days are target),
  the condition is: greater-equal 2011/11/27 06:00:00 and less-than 2011/11/28 06:00:00
 

Parameters:
dayBeginHour The local date-time that has the hour of day-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginDay_Hour(LocalDateTime dayBeginHour) {
         return doBeginDay_Hour(toDate(dayBeginHour));
     }

    
Begin day from the specified hour.
 e.g. beginDay_Hour(toDate("2001/01/01 06:00:00"))
  day is from 06h to 05h of next day
  (the 2011/11/27 means 2011/11/27 06h to 2011/11/28 05h)
 
 e.g. option.compareAsDate().beginDay_Hour(toDate("2001/01/01 06:00:00"))
  if from-date is 2011/11/27 and to-date is 2011/11/28 (means 27, 28 days are target),
  the condition is: greater-equal 2011/11/27 06:00:00 and less-than 2011/11/28 06:00:00
 

Parameters:
dayBeginHour The date that has the hour of day-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginDay_Hour(Date dayBeginHour) {
         return doBeginDay_Hour(dayBeginHour);
     }
 
     protected FromToOption doBeginDay_Hour(Date dayBeginHour) {
         assertPatternOptionValid("beginDay_Hour");
         assertArgumentNotNull("dayBeginHour"dayBeginHour);
          = toHandyDate(dayBeginHour).getHour();
         return this;
     }

    
Begin day from the specified hour.
 e.g. beginDay_Hour(6)
  day is from 06h to 05h of next day
  (the 2011/11/27 means 2011/11/27 06h to 2011/11/28 05h)
 
 e.g. option.compareAsDate().beginDay_Hour(6)
  if from-date is 2011/11/27 and to-date is 2011/11/28 (means 27, 28 days are target),
  the condition is: greater-equal 2011/11/27 06:00:00 and less-than 2011/11/28 06:00:00
 

Parameters:
dayBeginHour The day of day-begin. (NotMinus, 1-23)
Returns:
this. (NotNull)
 
     public FromToOption beginDay_Hour(int dayBeginHour) {
         assertPatternOptionValid("beginDay_Hour");
         assertNotMinusNotOver("dayBeginHour"dayBeginHour, 23);
          = dayBeginHour;
         return this;
     }

    
Begin day from the specified hour of previous day.
 e.g. beginDay_PreviousHour(22)
  day is from 22h of previous day to 21h of this day
  (the 2011/11/27 means 2011/11/26 22h to 2011/11/27 21h)
 
 e.g. option.compareAsDate().beginDay_PreviousHour(22)
  if from-date is 2011/11/27 and to-date is 2011/11/28 (means 27, 28 days are target),
  the condition is: greater-equal 2011/11/26 22:00:00 and less-than 2011/11/27 22:00:00
 

Parameters:
dayBeginHour The day of day-begin. (NotMinus, 1-23)
Returns:
this. (NotNull)
 
     public FromToOption beginDay_PreviousHour(int dayBeginHour) {
         assertPatternOptionValid("beginDay_PreviousHour");
         assertNotMinusNotOver("dayBeginHour"dayBeginHour, 23);
          = -dayBeginHour// to be minus
         return this;
     }
 
     // -----------------------------------------------------
     //                                            Begin Week
     //                                            ----------
     
Begin week from the specified day of week.
 e.g. beginWeek_DayOfWeek(toLocalDate("2011/11/28")) *means Monday
  week starts Monday (the 2011/11/27 belongs the week, 2011/11/21 to 2011/11/27)
 
 e.g. option.compareAsWeek().beginWeek_DayOfWeek(toLocalDate("2011/11/28")) *means Monday
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/21 and less-than 2011/12/05
 

Parameters:
weekBeginDayOfWeek The local date that has the day of day-of-week-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginWeek_DayOfWeek(LocalDate weekBeginDayOfWeek) {
         return doBeginWeek_DayOfWeek(toDate(weekBeginDayOfWeek));
     }

    
Begin week from the specified day of week.
 e.g. beginWeek_DayOfWeek(toLocalDateTime("2011/11/28")) *means Monday
  week starts Monday (the 2011/11/27 belongs the week, 2011/11/21 to 2011/11/27)
 
 e.g. option.compareAsWeek().beginWeek_DayOfWeek(toLocalDateTime("2011/11/28")) *means Monday
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/21 and less-than 2011/12/05
 

Parameters:
weekBeginDayOfWeek The local date-time that has the day of day-of-week-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginWeek_DayOfWeek(LocalDateTime weekBeginDayOfWeek) {
         return doBeginWeek_DayOfWeek(toDate(weekBeginDayOfWeek));
     }

    
Begin week from the specified day of week.
 e.g. beginWeek_DayOfWeek(toDate("2011/11/28")) *means Monday
  week starts Monday (the 2011/11/27 belongs the week, 2011/11/21 to 2011/11/27)
 
 e.g. option.compareAsWeek().beginWeek_DayOfWeek(toDate("2011/11/28")) *means Monday
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/21 and less-than 2011/12/05
 

Parameters:
weekBeginDayOfWeek The date that has the day of day-of-week-begin. (NotNull)
Returns:
this. (NotNull)
 
     public FromToOption beginWeek_DayOfWeek(Date weekBeginDayOfWeek) {
         return doBeginWeek_DayOfWeek(weekBeginDayOfWeek);
     }
 
     protected FromToOption doBeginWeek_DayOfWeek(Date weekBeginDayOfWeek) {
         assertPatternOptionValid("beginWeek_DayOfWeek");
         assertArgumentNotNull("weekBeginDayOfWeek"weekBeginDayOfWeek);
         return doBeginWeek(toHandyDate(weekBeginDayOfWeek).getDayOfWeek());
     }

    
Begin week from Sunday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek1st_Sunday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/20 and less-than 2011/12/04
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek1st_Sunday");
         return doBeginWeek(.);
     }

    
Begin week from Monday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek2nd_Monday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/21 and less-than 2011/12/05
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek2nd_Monday");
         return doBeginWeek(.);
     }

    
Begin week from Tuesday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek3rd_Tuesday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/22 and less-than 2011/12/06
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek3rd_Tuesday");
         return doBeginWeek(.);
     }

    
Begin week from Wednesday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek4th_Wednesday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/23 and less-than 2011/12/07
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek4th_Wednesday");
         return doBeginWeek(.);
     }

    
Begin week from Thursday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek5th_Thursday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/24 and less-than 2011/12/08
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek5th_Thursday");
         return doBeginWeek(.);
     }

    
Begin week from Friday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek6th_Friday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/18 and less-than 2011/12/02
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek6th_Friday");
         return doBeginWeek(.);
     }

    
Begin week from Saturday.
 e.g. option.compareAsWeek().beginWeek_DayOfWeek7th_Saturday()
  if from-date is 2011/11/24 and to-date is 2011/12/01 (means two weeks are target),
  the condition is: greater-equal 2011/11/19 and less-than 2011/12/03
 

Returns:
this. (NotNull)
 
         assertPatternOptionValid("beginWeek_DayOfWeek7th_Saturday");
         return doBeginWeek(.);
     }
 
     protected FromToOption doBeginWeek(int weekBeginDayOfWeek) {
          = weekBeginDayOfWeek;
         return this;
     }
 
     // -----------------------------------------------------
     //                                         Move-to Scope
     //                                         -------------
     
Move to the specified count of scope.
 e.g.
  compareAsYear().moveToScope(-1): 2011 to 2010 year
  compareAsMonth().moveToScope(-1): 11th to 10th month
  compareAsDate().moveToScope(2): 27 to 29 day
  compareAsHour().moveToScope(7): 12 to 19 hour
 
 e.g. compareAsDate().moveToScope(-1)
  if both from-date and to-date are 2011/11/27,
  the condition is: greater-equal 2011/11/26 and less-than 2011/11/27
 
  if both from-date is 2011/11/26 and to-date is 2011/11/28,
  the condition is: greater-equal 2011/11/25 and less-than 2011/11/28 
 
 e.g. compareAsDate() *normal (no move-to scope)
  if both from-date and to-date are 2011/11/27,
  the condition is: greater-equal 2011/11/27 and less-than 2011/11/28
 
  if both from-date is 2011/11/26 and to-date is 2011/11/28,
  the condition is: greater-equal 2011/11/26 and less-than 2011/11/29 
 

Parameters:
moveToCount The count to move-to. (MinusAllowed)
Returns:
this. (NotNull)
 
     public FromToOption moveToScope(int moveToCount) {
         assertPatternOptionValid("moveToScope");
          = moveToCount;
         return this;
     }
 
     // ===================================================================================
     //                                                                   Manual Adjustment
     //                                                                   =================
     // -----------------------------------------------------
     //                                                   All
     //                                                   ---
     protected void clearAll() {
         clearOperand();
         clearFromPattern();
         clearToPattern();
         clearFromDateWith();
         clearToDateWith();
          = false;
     }
 
     // -----------------------------------------------------
     //                                               Operand
     //                                               -------
     
Set up operand for from-date as greater-than.
This is for manual adjustment.

Returns:
this. (NotNull)
 
     public FromToOption greaterThan() {
         assertNotAdjustmentAfterPattern("greaterThan");
          = true;
         return this;
     }

    
Set up operand for to-date as less-than.
This is for manual adjustment.

Returns:
this. (NotNull)
 
     public FromToOption lessThan() {
         assertNotAdjustmentAfterPattern("lessThan");
          = true;
         return this;
     }
 
     public boolean isGreaterThan() { // basically for framework
         return ;
     }
 
     public boolean isLessThan() { // basically for framework
         return ;
     }
 
     protected void clearOperand() {
          = false;
          = false;
     }
 
     // -----------------------------------------------------
     //                                             From Date
     //                                             ---------
     public FromToOption fromPatternHourJust() {
         assertNotAdjustmentAfterPattern("fromPatternHourJust");
         clearFromPattern();
          = true;
         return this;
     }
 
     public FromToOption fromPatternDayJust() {
         assertNotAdjustmentAfterPattern("fromPatternDayJust");
         clearFromPattern();
          = true;
         return this;
     }
 
     public FromToOption fromPatternMonthJust() {
         assertNotAdjustmentAfterPattern("fromPatternMonthJust");
         clearFromPattern();
          = true;
         return this;
     }
 
        assertNotAdjustmentAfterPattern("fromPatternYearJust");
        clearFromPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("fromPatternWeekJust");
        clearFromPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("fromPatternQuarterOfYearJust");
        clearFromPattern();
         = true;
        return this;
    }
    protected void clearFromPattern() {
         = false;
         = false;
         = false;
         = false;
         = false;
         = false;
    }
    public FromToOption fromDateWithNoon() {
        clearFromDateWith();
         = true;
        return this;
    }
    public FromToOption fromDateWithHour(int hourOfDay) {
        clearFromDateWith();
         = hourOfDay;
        return this;
    }
    protected void clearFromDateWith() {
         = false;
         = null;
    }
    // -----------------------------------------------------
    //                                               To Date
    //                                               -------
        assertNotAdjustmentAfterPattern("toPatternNextHourJust");
        clearToPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("toPatternNextDayJust");
        clearToPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("toPatternNextMonthBegin");
        clearToPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("toPatternNextYearJust");
        clearToPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("toPatternNextWeekJust");
        clearToPattern();
         = true;
        return this;
    }
        assertNotAdjustmentAfterPattern("toPatternNextQuarterOfYearJust");
        clearToPattern();
         = true;
        return this;
    }
    protected void clearToPattern() {
         = false;
         = false;
         = false;
         = false;
         = false;
         = false;
    }
    public FromToOption toDateWithNoon() {
        clearToDateWith();
         = true;
        return this;
    }
    public FromToOption toDateWithHour(int hourOfDay) {
        clearToDateWith();
         = hourOfDay;
        return this;
    }
    protected void clearToDateWith() {
         = false;
         = null;
    }
    // ===================================================================================
    //                                                                      Plug-in Option
    //                                                                      ==============
    
Add 'or is null' to from-to conditions.

Returns:
this. (NotNull)
    public FromToOption orIsNull() {
         = true;
        return this;
    }

    
Does it add or-is-null to the condition?

Returns:
The determination, true or false.
    public boolean isOrIsNull() { // basically for framework
        return ;
    }

    
Allow you to set one-side only condition. (null allowed)
If you ignore null-or-empty query, you don't need to call this.

Returns:
this. (NotNull)
    public FromToOption allowOneSide() {
         = true;
        return this;
    }

    
Does it allow you to set one-side only condition.

Returns:
The determination, true or false.
    public boolean isOneSideAllowed() {
        return ;
    }
    // ===================================================================================
    //                                                                          Filte Date
    //                                                                          ==========
    public LocalDate filterFromDate(LocalDate fromDate) { // #date_parade
        final TimeZone timeZone = DBFluteSystem.getFinalTimeZone();
        return DfTypeUtil.toLocalDate(filterFromDate(DfTypeUtil.toDate(fromDatetimeZone)), timeZone);
    }

    
Filter the date as From. It requires this method is called before getFromDateConditionKey().

Parameters:
<DATE> The type of (util)Date.
fromDate The date as From. (NullAllowed: If the value is null, it returns null)
Returns:
The filtered date as From. (NullAllowed)
    public <DATE extends Date> DATE filterFromDate(DATE fromDate) {
        if (fromDate == null) {
            return null;
        }
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(fromDate.getTime());
        if () {
            moveToCalendarYearJust(cal);
            moveToScopeYear(cal);
        } else if () {
            moveToCalendarMonthJust(cal);
            moveToScopeMonth(cal);
        } else if () {
            moveToCalendarDayJust(cal);
            moveToScopeDay(cal);
        } else if () {
            moveToCalendarHourJust(cal);
            moveToScopeHour(cal);
        } else if () {
            moveToCalendarWeekJust(cal);
            moveToScopeWeek(cal);
        } else if () {
            moveToCalendarQuarterOfYearJust(cal);
            moveToScopeQuarterOfYear(cal);
        }
        if () {
            moveToCalendarHourJustNoon(cal);
        }
        if ( != null) {
            moveToCalendarHourJustFor(cal);
        }
        @SuppressWarnings("unchecked")
        final DATE cloneDate = (DATE) fromDate.clone();
        cloneDate.setTime(cal.getTimeInMillis());
        fromDate = cloneDate;
        return fromDate;
    }

    
Filter the date as To. It requires this method is called before getToDateConditionKey().

Parameters:
<DATE> The type of sub-class for java.util.Date.
toDate The date as To. (NullAllowed: If the value is null, it returns null)
Returns:
The filtered date as To. (NullAllowed)
    public <DATE extends Date> DATE filterToDate(DATE toDate) {
        if (toDate == null) {
            return null;
        }
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(toDate.getTime());
        if () {
            moveToCalendarNextYearJust(cal);
            moveToScopeYear(cal);
        } else if () {
            moveToCalendarNextMonthJust(cal);
            moveToScopeMonth(cal);
        } else if () {
            moveToCalendarNextDayJust(cal);
            moveToScopeDay(cal);
        } else if () {
            moveToCalendarNextHourJust(cal);
            moveToScopeHour(cal);
        } else if () {
            moveToCalendarNextWeekJust(cal);
            moveToScopeWeek(cal);
        } else if () {
            moveToCalendarNextQuarterOfYearJust(cal);
            moveToScopeQuarterOfYear(cal);
        }
        if () {
            moveToCalendarHourJustNoon(cal);
        }
        if ( != null) {
            moveToCalendarHourJustFor(cal);
        }
        @SuppressWarnings("unchecked")
        final DATE cloneDate = (DATE) toDate.clone();
        cloneDate.setTime(cal.getTimeInMillis());
        toDate = cloneDate;
        return toDate;
    }
    public Date xfilterToDateBetweenWay(Date toDate) {
        if (toDate == null) {
            return null;
        }
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(toDate.getTime());
        // moveToScope first because of using terminal
        if () {
            moveToScopeYear(cal);
            moveToCalendarYearTerminal(cal);
        } else if () {
            moveToScopeMonth(cal);
            moveToCalendarMonthTerminal(cal);
        } else if () {
            moveToScopeDay(cal);
            moveToCalendarDayTerminal(cal);
        } else if () {
            moveToScopeHour(cal);
            moveToCalendarHourTerminal(cal);
        } else if () {
            moveToScopeWeek(cal);
            moveToCalendarWeekTerminal(cal);
        } else if () {
            moveToScopeQuarterOfYear(cal);
            moveToCalendarQuarterOfYearTerminal(cal);
        }
        if () {
            moveToCalendarHourJustNoon(cal);
        }
        if ( != null) {
            moveToCalendarHourJustFor(cal);
        }
        final Date cloneDate = (DatetoDate.clone();
        cloneDate.setTime(cal.getTimeInMillis());
        toDate = cloneDate;
        return toDate;
    }
    protected Date filterNoon(Date date) {
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date.getTime());
        moveToCalendarHourJustNoon(cal);
        final Date cloneDate = (Datedate.clone();
        cloneDate.setTime(cal.getTimeInMillis());
        return cloneDate;
    }

    
Get the condition-key of the from-date. It requires this method is called after filterFromDate().

Returns:
The condition-key of the from-date. (NotNull)
        if () {
        } else { // as default
        }
    }

    
Get the condition-key of the to-date. It requires this method is called after filterToDate().

Returns:
The condition-key of the to-date. (NotNull)
        if () {
        } else { // as default
        }
    }
    // ===================================================================================
    //                                                                     Calendar Helper
    //                                                                     ===============
    // -----------------------------------------------------
    //                                          Move-to Just
    //                                          ------------
    protected void moveToCalendarYearJust(Calendar cal) {
        DfTypeUtil.moveToCalendarYearJust(cal);
    }
    protected void moveToCalendarMonthJust(Calendar cal) {
        DfTypeUtil.moveToCalendarMonthJust(cal);
    }
    protected void moveToCalendarDayJust(Calendar cal) {
        DfTypeUtil.moveToCalendarDayJust(cal);
    }
    protected void moveToCalendarHourJust(Calendar cal) {
        DfTypeUtil.moveToCalendarHourJust(cal);
    }
    protected void moveToCalendarHourJustFor(Calendar calint hourOfDay) {
        DfTypeUtil.moveToCalendarHourJustFor(calhourOfDay);
    }
    protected void moveToCalendarHourJustNoon(Calendar cal) {
        DfTypeUtil.moveToCalendarHourJustNoon(cal);
    }
    protected void moveToCalendarWeekJust(Calendar cal) {
        DfTypeUtil.moveToCalendarWeekJust(cal);
    }
    protected void moveToCalendarQuarterOfYearJust(Calendar cal) {
        DfTypeUtil.moveToCalendarQuarterOfYearJust(cal);
    }
    // -----------------------------------------------------
    //                                          Move-to Next
    //                                          ------------
    protected void moveToCalendarNextYearJust(Calendar cal) {
        moveToCalendarYearTerminal(cal);
        addCalendarMillisecondOne(cal);
    }
    protected void moveToCalendarNextMonthJust(Calendar cal) {
        moveToCalendarMonthTerminal(cal);
        addCalendarMillisecondOne(cal);
    }
    protected void moveToCalendarNextDayJust(Calendar cal) {
        moveToCalendarDayTerminal(cal);
        addCalendarMillisecondOne(cal);
    }
    protected void moveToCalendarNextHourJust(Calendar cal) {
        moveToCalendarHourTerminal(cal);
        addCalendarMillisecondOne(cal);
    }
    protected void moveToCalendarNextWeekJust(Calendar cal) {
        moveToCalendarWeekTerminal(cal);
        addCalendarMillisecondOne(cal);
    }
    protected void moveToCalendarNextQuarterOfYearJust(Calendar cal) {
        addCalendarMillisecondOne(cal);
    }
    protected void addCalendarMillisecondOne(Calendar cal) {
        DfTypeUtil.addCalendarMillisecond(cal, 1);
    }
    // -----------------------------------------------------
    //                                      Move-to Terminal
    //                                      ----------------
    protected void moveToCalendarYearTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarYearTerminal(cal);
    }
    protected void moveToCalendarMonthTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarMonthTerminal(cal);
    }
    protected void moveToCalendarDayTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarDayTerminal(cal);
    }
    protected void moveToCalendarHourTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarHourTerminal(cal);
    }
    protected void moveToCalendarWeekTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarWeekTerminal(cal);
    }
    protected void moveToCalendarQuarterOfYearTerminal(Calendar cal) {
        DfTypeUtil.moveToCalendarQuarterOfYearTerminal(cal);
    }
    // -----------------------------------------------------
    //                                         Move-to Scope
    //                                         -------------
    protected void moveToScopeYear(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarYear(cal);
        }
    }
    protected void moveToScopeMonth(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarMonth(cal);
        }
    }
    protected void moveToScopeDay(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarDay(cal);
        }
    }
    protected void moveToScopeHour(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarHour(cal);
        }
    }
    protected void moveToScopeWeek(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarWeek(cal);
        }
    }
    protected void moveToScopeQuarterOfYear(Calendar cal) {
        if ( != null) {
            DfTypeUtil.addCalendarQuarterOfYear(cal);
        }
    }
    // ===================================================================================
    //                                                                            TimeZone
    //                                                                            ========
    
Set time-zone, basically for LocalDate conversion.
Normally you don't need to set this, you can adjust other ways.
(DBFlute system's time-zone is used as default)

Parameters:
timeZone The time-zone for filtering. (NullAllowed: if null, default zone)
Returns:
this. (NotNull)
    public FromToOption zone(TimeZone timeZone) {
         = timeZone;
        return this;
    }

    
Get the time-zone in this option basically for filtering.

Returns:
The time-zone for filtering. (NotNull: if no setting, system zone)
    public TimeZone getTimeZone() {
        return  != null ?  : getDBFluteSystemFinalTimeZone();
    }
        return DBFluteSystem.getFinalTimeZone();
    }
    // ===================================================================================
    //                                                            Interface Implementation
    //                                                            ========================
    public String getRearOption() {
        return "";
    }
    public boolean hasCompoundColumn() {
        return false;
    }
        return DfCollectionUtil.emptyList();
    }
    public boolean hasStringConnector() {
        return false;
    }
        return null;
    }
        return null;
    }
        return null;
    }
        return null;
    }
    // ===================================================================================
    //                                                                        Small Helper
    //                                                                        ============
    protected Date toDate(LocalDate date) {
        return DfTypeUtil.toDate(dategetTimeZone());
    }
    protected Date toDate(LocalDateTime date) {
        return DfTypeUtil.toDate(dategetTimeZone());
    }
    protected HandyDate toHandyDate(Date date) {
        return new HandyDate(date).timeZone(getTimeZone());
    }
    // ===================================================================================
    //                                                                       Assert Helper
    //                                                                       =============
    protected void assertArgumentNotNull(String nameObject value) {
        if (value == null) {
            String msg = "The argument '" + name + "' should not be null.";
            throw new IllegalArgumentException(msg);
        }
    }
    protected void assertNotMinusNotOver(String nameint valueint max) {
        if (value < 0) {
            String msg = "The argument '" + name + "' should not be minus: value=" + value;
            throw new IllegalArgumentException(msg);
        }
        if (value > max) {
            String msg = "The argument '" + name + "' should not be over: value=" + value + " max=" + max;
            throw new IllegalArgumentException(msg);
        }
    }
    protected void assertPatternOptionValid(String option) {
        if (!) {
            String msg = "The option '" + option + "()' should be called after pattern setting.";
            throw new IllegalStateException(msg);
        }
    }
    protected void assertNotAdjustmentAfterPattern(String option) {
        if () {
            String msg = "The option '" + option + "()' should not be call after pattern setting.";
            throw new IllegalStateException(msg);
        }
    }
    // ===================================================================================
    //                                                                      Basic Override
    //                                                                      ==============
    @Override
    public String toString() {
        final String title = DfTypeUtil.toClassTitle(this);
        final StringBuilder sb = new StringBuilder();
        sb.append(title);
        sb.append(":{usePattern=").append();
        sb.append(", greaterThan=").append().append(", lessThan=").append();
        sb.append(", orIsNull=").append();
        sb.append(", oneSideAllowed=").append();
        sb.append("}");
        return sb.toString();
    }