Package java.util

Examples of java.util.GregorianCalendar.before()


      GregorianCalendar endCalendar = new GregorianCalendar(Integer.parseInt(yearEndValue.trim()),
          Integer.parseInt(monthEndValue.trim()), Integer.parseInt(dayEndValue.trim()), Integer
              .parseInt(endHour.trim()), Integer.parseInt(endMinute.trim()));

      // compare start date and end date
      if (endCalendar.before(startCalendar)) {
        isError = true;
      } else {
        isError = false;
      }
View Full Code Here


        // get end calendar
        endCalendar = new GregorianCalendar(Integer.parseInt(yearEndValue.trim()), Integer
            .parseInt(monthEndValue.trim()), Integer.parseInt(dayEndValue.trim()), 00, 00);

        // compare start date and end date
        if (endCalendar.before(startCalendar)) {
          // if error then error is in date
          isError = true;
          ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldEndDateLabel),
              messages.getMessage(fieldStartDateLabel));
          actionErrors.add(errorKey, error);
View Full Code Here

      // get end calendar
      GregorianCalendar endCalendar = new GregorianCalendar(Integer.parseInt(yearEndValue), Integer
          .parseInt(monthEndValue), Integer.parseInt(dayEndValue));

      // compare start date and end date
      if (endCalendar.before(startCalendar)) {
        isError = true;
      } else {
        isError = false;
      }
    } catch (Exception e) {
View Full Code Here

      int factor = 0; //to correctly calculate age when birthday has not been yet celebrated

      dobCal.setTime(dob);
      dayCal.setTime(day);
     
      if(dayCal.before(dobCal))
        throw new IllegalArgumentException(String.format("Date of birth %tF cannot be after comparison day %tF", dob, day ));
     
      // check if birthday has been celebrated this year
      if(dayOfYearProxy(dayCal)< dayOfYearProxy(dobCal)) {
              factor = -1; //birthday not celebrated
View Full Code Here

        gc2.clear(Calendar.MILLISECOND);
        gc2.clear(Calendar.SECOND);
        gc2.clear(Calendar.MINUTE);
        gc2.clear(Calendar.HOUR_OF_DAY);

        while (gc1.before(gc2)) {
            gc1.add(Calendar.DATE, 1);
            elapsed++;
        }
        return elapsed+1; // always include today
    }
View Full Code Here

                        System.err.println("Invalid time argument.");
                        return null;
                    }
                    GregorianCalendar currentDate = new GregorianCalendar();
                    GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
                    if (shutdownDate.before(currentDate)) {
                        shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
                    }
                    sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
                }
            }
View Full Code Here

    // Test leap year if current year is a leap year
    public void testFeb29IfLeapYear() throws Exception{
        GregorianCalendar now = new GregorianCalendar();
        final int thisYear = now.get(Calendar.YEAR);
        if (now.isLeapYear(thisYear) && now.before(new GregorianCalendar(thisYear,Calendar.AUGUST,29))){
            GregorianCalendar target = new GregorianCalendar(thisYear,Calendar.FEBRUARY,29);
            checkShortParse("Feb 29th",now,target);
        } else {
            System.out.println("Skipping Feb 29 test");
        }
View Full Code Here

                        System.err.println("Invalid time argument.");
                        return null;
                    }
                    GregorianCalendar currentDate = new GregorianCalendar();
                    GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
                    if (shutdownDate.before(currentDate)) {
                        shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
                    }
                    sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
                }
            }
View Full Code Here

                    if (strings.length != 2) {
                        throw new IllegalArgumentException("Time " + time + " is not valid");
                    }
                    GregorianCalendar currentDate = new GregorianCalendar();
                    GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
                    if (shutdownDate.before(currentDate)) {
                        shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
                    }
                    sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
                }
            }
View Full Code Here

                    if (minute < 0 || minute > 59) {
                        throw new IllegalArgumentException("Time " + time + " is not valid (minute " + minute + " is not between 0 and 59)");
                    }
                    GregorianCalendar currentDate = new GregorianCalendar();
                    GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DAY_OF_MONTH), hour, minute);
                    if (shutdownDate.before(currentDate)) {
                        shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
                    }
                    sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
                } else {
                    if (time.startsWith("+")) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.