Package java.util

Examples of java.util.GregorianCalendar.before()


    }
    GregorianCalendar        calendarFrom = new GregorianCalendar();
    calendarFrom.setTime(from);
    GregorianCalendar        calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean              negative = calendarTo.before(calendarFrom);
    int                yearDif = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    calendarTo.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    if (calendarTo.before(calendarFrom)) {
      if (!negative) {
        yearDif -= 1;
View Full Code Here


    GregorianCalendar        calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean              negative = calendarTo.before(calendarFrom);
    int                yearDif = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    calendarTo.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    if (calendarTo.before(calendarFrom)) {
      if (!negative) {
        yearDif -= 1;
      }
    }
    else{
View Full Code Here

    }
    GregorianCalendar      calendarFrom = new GregorianCalendar();
    calendarFrom.setTime(from);
    GregorianCalendar      calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean            negative = calendarTo.before(calendarFrom);
    int              yearBase = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    int              monthDiff = calendarTo.get(GregorianCalendar.MONTH) - calendarFrom.get(GregorianCalendar.MONTH);
    monthDiff += yearBase * 12;
    calendarFrom.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    calendarFrom.set(GregorianCalendar.MONTH, calendarFrom.get(GregorianCalendar.MONTH));
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), 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();
                } else {
                    if (time.startsWith("+")) {
View Full Code Here

      fromCal.setTime(from);
      long diffYears = 0;
      long diffMonths = -1;
      int fromMonth = fromCal.get(Calendar.MONTH);
      int currentMonth;
      for (; fromCal.before(toCal);) {
        fromCal.add(Calendar.MONTH, 1);
        ++diffMonths;
        currentMonth = fromCal.get(Calendar.MONTH);
        if (currentMonth == fromMonth)
          ++diffYears;
View Full Code Here

    }
    GregorianCalendar        calendarFrom = new GregorianCalendar();
    calendarFrom.setTime(from);
    GregorianCalendar        calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean              negative = calendarTo.before(calendarFrom);
    int                yearDif = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    calendarTo.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    if (calendarTo.before(calendarFrom)) {
      if (!negative) {
        yearDif -= 1;
View Full Code Here

    GregorianCalendar        calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean              negative = calendarTo.before(calendarFrom);
    int                yearDif = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    calendarTo.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    if (calendarTo.before(calendarFrom)) {
      if (!negative) {
        yearDif -= 1;
      }
    }
    else{
View Full Code Here

    }
    GregorianCalendar      calendarFrom = new GregorianCalendar();
    calendarFrom.setTime(from);
    GregorianCalendar      calendarTo = new GregorianCalendar();
    calendarTo.setTime(to);
    boolean            negative = calendarTo.before(calendarFrom);
    int              yearBase = calendarTo.get(GregorianCalendar.YEAR) - calendarFrom.get(GregorianCalendar.YEAR);
    int              monthDiff = calendarTo.get(GregorianCalendar.MONTH) - calendarFrom.get(GregorianCalendar.MONTH);
    monthDiff += yearBase * 12;
    calendarFrom.set(GregorianCalendar.YEAR, calendarFrom.get(GregorianCalendar.YEAR));
    calendarFrom.set(GregorianCalendar.MONTH, calendarFrom.get(GregorianCalendar.MONTH));
View Full Code Here

   * @return true, if is already in session
   */
  public static boolean isAlreadyInSession(String userId){
    boolean isAlreadyConnected = false;
    GregorianCalendar actualCalendar = new GregorianCalendar(TimeZone.getTimeZone("GTM"), Locale.ENGLISH);
    if(actualCalendar.before(sessions.get(userId))) isAlreadyConnected = true;
    return isAlreadyConnected;
  }
 
  public static void removeFromSession(String userId) {
    sessions.remove(userId);
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.