Package java.util

Examples of java.util.GregorianCalendar


      String callType = activityForm.getActivityCallType();
      activity.setCallTypeId(Integer.parseInt(callType));
    }

    if (CVUtility.notEmpty(activityForm.getActivityStartDate())) {
      Calendar start = new GregorianCalendar();
      Calendar startTime = new GregorianCalendar();
      try {
        logger.debug("dateformat: "+df.toString()+", lenient?: "+df.isLenient()+", locale: "+activityForm.getLocale());
        start.setTime(df.parse(activityForm.getActivityStartDate()));
        startTime.setTime(tf.parse(activityForm.getActivityStartTime()));
        logger.debug("parsed start date: "+df.format(start.getTime()));
        logger.debug("parsed start time: "+tf.format(startTime.getTime()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Can't parse start date or time", e);
      }
      start.set(Calendar.HOUR, startTime.get(Calendar.HOUR));
      start.set(Calendar.MINUTE, startTime.get(Calendar.MINUTE));
      start.set(Calendar.AM_PM, startTime.get(Calendar.AM_PM));
      activity.setActivityStartDate(new Timestamp(start.getTimeInMillis()));
    }

    if (CVUtility.notEmpty(activityForm.getActivityEndDate())) {
      Calendar end = new GregorianCalendar();
      Calendar endTime = new GregorianCalendar();
      try {
        end.setTime(df.parse(activityForm.getActivityEndDate()));
        endTime.setTime(tf.parse(activityForm.getActivityEndTime()));
        logger.debug("parsed end date: "+df.format(end.getTime()));
        logger.debug("parsed end time: "+tf.format(endTime.getTime()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Can't parse end date or time", e);
      }
      end.set(Calendar.HOUR, endTime.get(Calendar.HOUR));
      end.set(Calendar.MINUTE, endTime.get(Calendar.MINUTE));
      end.set(Calendar.AM_PM, endTime.get(Calendar.AM_PM));
      activity.setActivityEndDate(new Timestamp(end.getTimeInMillis()));
    }

    if ((activityForm.getActivityOwnerID() != null)
        && (activityForm.getActivityOwnerID().length() > 0)) {
      activity.setOwner(Integer.parseInt(activityForm.getActivityOwnerID()));
    }
    try {
      String tmpPriority = activityForm.getActivityPriority();
      if ((tmpPriority != null) && (!tmpPriority.equals(""))) {
        activity.setPriority(Integer.parseInt(tmpPriority));
      } else {
        activity.setPriority(2);
      }
    } catch (Exception e) {
      activity.setPriority(2);
    }
    if ((activityForm.getActivityNotes() != null) && (activityForm.getActivityNotes().length() > 0)) {
      activity.setNotes(activityForm.getActivityNotes());
    }
    try {
      String tmpStatus = activityForm.getActivityStatus();
      if ((tmpStatus != null) && (!tmpStatus.equals(""))) {
        activity.setStatus(Integer.parseInt(tmpStatus));
      } else {
        activity.setStatus(2);
      }
    } catch (Exception e) {
      activity.setStatus(2);
    }
    activity.setVisibility(activityForm.getActivityVisibility());
    String reminder = activityForm.getActivityReminder();
    if (activityForm.getActivityReminder() != null && reminder.equals("on")) {
      ActivityActionVO action = new ActivityActionVO();
      action.setActionType(ActivityActionVO.AA_ALERT);
      // FIXME externalize String
      action.setMessage("Scheduled Alert: " + activity.getTitle());
      action.setInterval(0);
      action.setRepeat(0);
      if (CVUtility.notEmpty(activityForm.getActivityRemindDate())
          && CVUtility.notEmpty(activityForm.getActivityReminderTime())) {
        Calendar remind = new GregorianCalendar();
        Calendar remindTime = new GregorianCalendar();
        try {
          remind.setTime(df.parse(activityForm.getActivityRemindDate()));
          remindTime.setTime(tf.parse(activityForm.getActivityReminderTime()));
        } catch (ParseException e) {
          logger.error("[fillBasic]: Exception", e);
        }
        remind.set(Calendar.HOUR, remindTime.get(Calendar.HOUR));
        remind.set(Calendar.MINUTE, remindTime.get(Calendar.MINUTE));
        remind.set(Calendar.AM_PM, remindTime.get(Calendar.AM_PM));
        action.setActionTime(new Timestamp(remind.getTimeInMillis()));
      }
      action.setRecipient(activity.getOwner());
      activity.setActivityAction(action);
    } // end if (activityForm.getActivityReminder() != null &&
    // reminder.equals("on"))
    String emailinvitation = activityForm.getActivityEmailInvitation();
    if (activityForm.getActivityEmailInvitation() != null && emailinvitation.equals("on")) {
      ActivityActionVO activityactionvo = new ActivityActionVO();
      activityactionvo.setActionType(ActivityActionVO.AA_EMAIL);
      activityactionvo.setMessage("Invitation : " + activity.getTitle());
      activityactionvo.setInterval(0);
      activityactionvo.setRepeat(0);
      String[] attendeerequired = activityForm.getActivityAttendeesRequired();
      String[] attendeeoptional = activityForm.getActivityAttendeesOptional();
      if (attendeerequired != null) {
        for (int i = 0; i < attendeerequired.length; i++) {
          try {
            int indexOfHash = attendeerequired[i].indexOf("#");
            String idName = attendeerequired[i].substring(0, indexOfHash);
            activityactionvo.setRecipient(Integer.parseInt(idName));
          }// end of try block
          catch (Exception e) {}// end of catch block
        }// end of for( int i=0 ; i < attendeerequired.length ; i ++ )
      }// end of if (attendeerequired != null)
      if (attendeeoptional != null) {
        for (int j = 0; j < attendeeoptional.length; j++) {
          try {
            int indexOfHash = attendeeoptional[j].indexOf("#");
            String idName = attendeeoptional[j].substring(0, indexOfHash);
            activityactionvo.setRecipient(Integer.parseInt(idName));
          } // end of try block
          catch (Exception e) {}// end of catch block
        }// end of for( int j=0 ; j < attendeeoptional.length ; j ++ )
      }// end of if (attendeeoptional != null)
      activity.setActivityAction(activityactionvo);
    }// end of if (activityForm.getActivityEmailInvitation() != null &&.......)
    String freq = activityForm.getActivityRecurringFrequency();
    if ((freq != null) && (freq.length() > 0)
        && (CVUtility.notEmpty(activityForm.getActivityRecurStartDate()))) {
      RecurrenceVO recur = new RecurrenceVO();

      Calendar recurStart = new GregorianCalendar();
      try {
        recurStart.setTime(df.parse(activityForm.getActivityRecurStartDate()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Exception", e);
      }
      recur.setStartDate(new Date(recurStart.getTimeInMillis()));

      if (CVUtility.notEmpty(activityForm.getActivityRecurEndDate())) {
        Calendar recurEnd = new GregorianCalendar();
        try {
          recurEnd.setTime(df.parse(activityForm.getActivityRecurEndDate()));
        } catch (ParseException e) {
          logger.error("[fillBasic]: Exception", e);
        }
        recur.setUntil(new Date(recurEnd.getTimeInMillis()));
      }
      recur.setTimePeriod(activityForm.getActivityRecurringFrequency());
      HashMap mapRecurrence = new HashMap();
      mapRecurrence.put("FREQUENCY", activityForm.getActivityRecurringFrequency());
      boolean isRecurr = false;
View Full Code Here


    java.util.Date date = new java.util.Date(time);

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);

    GregorianCalendar gregCal = new GregorianCalendar();
    gregCal.setTimeInMillis(time);

    XMLGregorianCalendar xmlGregCal = getXMLGregorianCalendar(time);

    DateFormat[] dateFormats = new DateFormat[] { DateFormat.getDateInstance(DateFormat.FULL),
        DateFormat.getDateInstance(DateFormat.LONG), DateFormat.getDateInstance(DateFormat.MEDIUM),
View Full Code Here

          classes[i], null));
    }
  }

  private XMLGregorianCalendar getXMLGregorianCalendar(long millis) {
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(millis);
    XMLGregorianCalendar cal = null;

    try {
      cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
    } catch (Exception ignore) {
View Full Code Here

    assertEquals(date, result);
  }

  @Test
  public void testCalendarConversion() {
    GregorianCalendar calendar = new GregorianCalendar(1, 2, 3);
    GregorianCalendar result = (GregorianCalendar) converter.convert(GregorianCalendar.class, calendar);
    assertEquals(calendar, result);
  }
View Full Code Here

    assertNull(converter.convert(Date.class, ""));
  }

  @Test
  public void testGoodString() {
    GregorianCalendar calendar = new GregorianCalendar(2001, 1, 1);
    java.util.Date expected = calendar.getTime();
    assertEquals(expected, converter.convert(java.util.Date.class, "01.02.2001"));
  }
View Full Code Here

  }

  @Test
  public void testXmlGregorianCalendar() {
    XMLGregorianCalendar xmlCalendar = mock(XMLGregorianCalendar.class);
    GregorianCalendar expected = new GregorianCalendar();
    when(xmlCalendar.toGregorianCalendar()).thenReturn(expected);
    Date date = new Date(expected.getTimeInMillis());

    assertEquals(date, converter.convert(Date.class, xmlCalendar));
  }
View Full Code Here

  }

  @Test
  public void testConvert_XmlGregorianCalendar() throws Exception {
    DatatypeFactory instance = DatatypeFactory.newInstance();
    XMLGregorianCalendar calendar = instance.newXMLGregorianCalendar(new GregorianCalendar(YEAR, MONTH, DAY));

    Object result = converter.convert(XMLGregorianCalendar.class, calendar);
    XMLGregorianCalendar xmlCalendar = (XMLGregorianCalendar) result;

    assertEquals(YEAR, xmlCalendar.getYear());
View Full Code Here

        // Changed DATE format By Shilpa
        String dateFormat = "M/d/yyyy - h:mm a";

        String timeZone = "EST";
        GregorianCalendar gCal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
        SimpleDateFormat dForm = new SimpleDateFormat(dateFormat);
        dForm.setCalendar(gCal);

        Timestamp ts = (Timestamp)hm.get("Created");

        String createdDt = dForm.format(ts);

        ts = (Timestamp)hm.get("Modified");

        String modifiedDt = dForm.format(ts);
        // By Shilpa ends here

        proposallistform.setCreatedDate(createdDt);
        proposallistform.setModifyDate(modifiedDt);
        if (hm.get("Billing") != null) {
          proposallistform.setBillingaddress(hm.get("Billing").toString());
        } else {
          proposallistform.setBillingaddress("");
        }

        if (hm.get("Shipping") != null) {
          proposallistform.setShippingaddress(hm.get("Shipping").toString());
        } else {
          proposallistform.setShippingaddress("");
        }
        proposallistform.setBillingaddressid(hm.get("Billingid").toString());
        proposallistform.setShippingaddressid(hm.get("Shippingid").toString());
        int jurisdictionID = 0;
        if (hm.get("jurisdictionID") != null) {
          jurisdictionID = ((Number)hm.get("jurisdictionID")).intValue();
        }
        proposallistform.setJurisdictionID(jurisdictionID);

        int iShippingId = Integer.parseInt(hm.get("Shippingid").toString());
        proposallistform.setSpecialinstructions(hm.get("Instructions").toString());
        proposallistform.setForecastinc(hm.get("IncludeForcastSale").toString());
        proposallistform.setForcastAmount(currencyFormat.format(hm.get("ForecastAmmount")));
        proposallistform.setTerms((hm.get("termid")).toString());

        int orderID = ((Number)hm.get("orderID")).intValue();

        proposallistform.setOrderID(orderID);

        Timestamp ec = (Timestamp)hm.get("EstimatedCloseDate");
        Calendar estimatedClose = new GregorianCalendar();
        estimatedClose.setTimeInMillis(ec.getTime());
        Timestamp ac = (Timestamp)hm.get("ActualCloseDate");
        Calendar actualClose = new GregorianCalendar();
        actualClose.setTimeInMillis(ac.getTime());

        if (ec != null) {
          proposallistform.setEcday(String.valueOf(estimatedClose.get(Calendar.DATE)));
          proposallistform.setEcmon(String.valueOf(estimatedClose.get(Calendar.MONTH)+1));
          proposallistform.setEcyear(String.valueOf(estimatedClose.get(Calendar.YEAR)));
        } else {
          proposallistform.setEcday("");
          proposallistform.setEcmon("");
          proposallistform.setEcyear("");
        } // end of if statement (ec != null)

        if (ac != null) {
          proposallistform.setAcday(String.valueOf(actualClose.get(Calendar.DATE)));
          proposallistform.setAcmon(String.valueOf(actualClose.get(Calendar.MONTH)+1));
          proposallistform.setAcyear(String.valueOf(actualClose.get(Calendar.YEAR)));
        } else {
          proposallistform.setAcday("");
          proposallistform.setAcmon("");
          proposallistform.setAcyear("");
        } // end of else statement (ac != null)
View Full Code Here

                }
                return getTimeTry(true, tz, year, month, day, hour, minute, second, millis);
            } else if (message.indexOf("DAY_OF_MONTH") > 0) {
                int maxDay;
                if (month == 2) {
                    maxDay = new GregorianCalendar().isLeapYear(year) ? 29 : 28;
                } else {
                    maxDay = 30 + ((month + (month > 7 ? 1 : 0)) & 1);
                }
                if (day < 1 || day > maxDay) {
                    throw e;
View Full Code Here

            if (year < 0) {
                year++;
            }
           
            // set it into a calendar
            GregorianCalendar cal;
            if (year < 1800) {
                cal = new GregorianCalendar();
                cal.setGregorianChange(BEGINNING_OF_TIME);
                cal.clear();
                cal.set(year, month, day+1);
            } else {
                cal = new GregorianCalendar(year, month, day+1);
            }
            return new java.sql.Date(cal.getTime().getTime());
        }
    }
View Full Code Here

TOP

Related Classes of java.util.GregorianCalendar

Copyright © 2018 www.massapicom. 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.