Package java.util

Examples of java.util.GregorianCalendar


    int individualId = user.getIndividualID();
    TimeZone tz = TimeZone.getTimeZone((user.getUserPref()).getTimeZone());

    //UserPrefererences preferences = user.getUserPref();

    GregorianCalendar startTime = new GregorianCalendar(tz, locale);
    startTime.setTime(Calendar.getInstance().getTime());
    startTime.set(startTime.get(Calendar.YEAR), startTime.get(Calendar.MONTH), startTime
        .get(Calendar.DATE), 0, 0);

    GregorianCalendar endTime = new GregorianCalendar(tz, locale);
    endTime.setTime(Calendar.getInstance().getTime());
    endTime.set(startTime.get(Calendar.YEAR), startTime.get(Calendar.MONTH), startTime
        .get(Calendar.DATE), 0, 0);
    endTime.add(Calendar.DATE, 1);
    // The calendar map has a bunch of stuff in it, it will be used for a few of
    // the portlets
    // set up below.
    HashMap calendarMap = CalendarUtil.getCalendarCollection(startTime, endTime, tz, individualId,
        60, "", dataSource);
View Full Code Here


      String detailtitle = requestForm.getTitle();
      String detaildetail = requestForm.getDescription();

      // startdate
      Calendar start = new GregorianCalendar(tz, locale);
      String activityStartDate = requestForm.getStartDateTime();
      if (activityStartDate != null && (!activityStartDate.equals(""))) {
        try {
          Date dd = simpleDateFormat.parse(activityStartDate);
          start.setTime(dd);
        } catch (Exception e) {
          logger.error("[execute]: Exception", e);
        }
      }
      activityForm.setActivityStartDate(df.format(start.getTime()));
      activityForm.setActivityStartTime(tf.format(start.getTime()));

      // enddate
      Calendar end = new GregorianCalendar(tz, locale);
      String activityenddate = requestForm.getEndDateTime();
      if (activityenddate != null && (!activityenddate.equals(""))) {
        try {
          Date dd = simpleDateFormat.parse(activityenddate);
          end.setTime(dd);
        } catch (Exception e) {
          logger.error("[execute]: Exception", e);
        }
      }
      activityForm.setActivityEndDate(df.format(end.getTime()));
      activityForm.setActivityEndTime(tf.format(end.getTime()));

      activityForm.setActivityPriority(detailpriority);
      activityForm.setActivityStatus(detailstatus);
      activityForm.setActivityTitle(detailtitle);
      activityForm.setActivityDetail(detaildetail);

      // alarm date time
      String alarmDateTime = requestForm.getAlarmDateTime(); // alarmDateTime
      // ="01/09/2003";
      if (alarmDateTime != null && (!alarmDateTime.equals(""))) {
        try {
          Date d = simpleDateFormat.parse(alarmDateTime);
          GregorianCalendar remind = new GregorianCalendar();
          remind.setTime(d);
          activityForm.setActivityRemindDate(df.format(remind.getTime()));
          activityForm.setActivityReminder("on");
        } catch (Exception e) {
          logger.error("[execute]: Exception", e);
        }
      }

      // now, add the Activity to the database using our SyncFacade bean
      String linkCompany = requestForm.getLinkCompany();
      if (linkCompany == null) {
        activityForm.setLinkCompany(linkCompany);
      }

      // create an instance of our SyncFacade EJB
      SyncFacade syncfacade = new SyncFacade();
      syncfacade.setDataSource(dataSource);

      // now, add the Activity to the database using our SyncFacade bean
      String activitytype = requestForm.getType();
      if (activitytype == null) {
        activitytype = "Appointment";
      }
      String result = "";

      int individualID = userobjectd.getIndividualID();
      // Appointment
      if (activitytype.equals("Appointment")) {
        activityForm.setActivityType("1");
      }

      // Call
      if (activitytype.equals("Call")) {
        activityForm.setActivityType("2");
      }

      // Meeting
      if (activitytype.equals("Meeting")) {
        activityForm.setActivityType("5");
      }

      // ToDo
      if (activitytype.equals("To Do")) {
        activityForm.setActivityType("6");
      }

      // NextAction
      if (activitytype.equals("Next Action")) {
        activityForm.setActivityType("7");
      }

      result = syncfacade.addActivity(activityForm, individualID);

      com.centraview.syncfacade.SyncFacade sfremote = null;
      try {
        SyncFacadeHome syncHome = (SyncFacadeHome)CVUtility.getHomeObject(
            "com.centraview.syncfacade.SyncFacadeHome", "SyncFacade");
        sfremote = syncHome.create();
        sfremote.setDataSource(dataSource);
      } catch (Exception e) {
        logger.error("[execute]: Exception", e);
        writer.print("FAIL");
        return (null);
      }

      // Check to see if the user's preference is to create sync'ed
      // records as private. If so, delete all records from recordauthorisation
      // and publicrecords tables that link to the newly created records.
      if (syncAsPrivate) {
        ArrayList recordIDs = new ArrayList();
        try {
          recordIDs.add(new Integer(result));
        } catch (NumberFormatException nfe) {
          // don't need to do anything, because we obviously didn't add an
          // activity successfully.
          System.out.println("\n\n\nCAUGHT A NumberFormatException!!!!\n\n\n");
        }
        sfremote.markRecordsPrivate(3, recordIDs);
      }

      // we need to make all the Activities lists dirty, so that the next time
      // they are viewed, they are refreshed and contain the record we just
      // added
      ListGenerator lg = ListGenerator.getListGenerator(dataSource);
      lg.makeListDirty("MultiActivity");
      lg.makeListDirty("AllActivity");
      lg.makeListDirty("Appointment");
      lg.makeListDirty("Call");
      lg.makeListDirty("Meeting");
      lg.makeListDirty("NextAction");
      lg.makeListDirty("ToDo");

      // Now we check to see if this is a recurring activity.
      // Check the "recurrenceType" field. If it is not null,
      // then process the other recurring fields "every" and "on".
      // Then call the SyncFacadeEJB to add the recurring data
      // to the recurrence table.
      String recurrenceType = requestForm.getRecurrenceType();

      if (result != null && !result.equals("")) {
        // only do this if we actually created an activity above
        if (recurrenceType != null && !recurrenceType.equals("")) {
          // this is a recurring activity, get the other recurring fields
          String every = requestForm.getEvery();
          String recurrOn = requestForm.getOn();

          // NOTE: we do not care about recurringStartDate anymore, only copy
          // startDateTime into recurringStartDate
          String recurringStartDateString = requestForm.getStartDateTime();
          String recurringEndDateString = requestForm.getRecurrenceEndDate();

          Date recurringStartDate = null;
          Date recurringEndDate = null;

          try {
            recurringStartDate = simpleDateFormat.parse(recurringStartDateString);
            if (recurringEndDateString != null) {
              recurringEndDate = simpleDateFormat.parse(recurringEndDateString);
            } else {
              recurringEndDate = simpleDateFormat.parse("2099-12-31 00:00:00");
            }

            // NOTE: There is a bug in the CompanionLink Client API, that is
            // sending us the day of the month in the "every" field, instead of
            // the month of the year; when the recurring type is Yearly. To fix
            // this issue, we now get the month of the year from the start date,
            // and set every equal to that value. When CompanionLink addresses
            // this issue correctly, we can remove this hack.
            if (recurrenceType.equals("YEAR")) {
              Calendar recurStart = new GregorianCalendar(tz, locale);
              recurStart.setTime(recurringStartDate);
              every = String.valueOf(recurStart.get(Calendar.MONTH));
            }
            // END HACK for yearly bug from CompanionLink

            // next line returns boolean, but there's no real reason to check.
            // (since we can't ROLLBACK)
View Full Code Here

  /**
   * Runs the thread that polls for incoming commands.
   */
  public void run()
  {
    GregorianCalendar prevPingTime = new GregorianCalendar();
    while(true)
    {
      if(this instanceof NotificationServer)
        pingIfRequired(prevPingTime);

View Full Code Here

   *
   * @param prevPingTime the last time when ping command was sent
   */
  private void pingIfRequired(GregorianCalendar prevPingTime)
  {
    GregorianCalendar now = new GregorianCalendar();
    prevPingTime.add(GregorianCalendar.SECOND, 119);
    if(now.after(prevPingTime))
    {
      Command png = new Command("PNG");

      synchronized(writeBuffer)
      {
View Full Code Here

   {
      String[] arr = dateTime.split(SPLIT_REGEX, 7);
      int valid = Integer.parseInt(arr[0]);
      if (valid < 1 || valid > 12)
         return false;
      Calendar date = new GregorianCalendar(Integer.parseInt(arr[2]), valid - 1, 1);
      if (Integer.parseInt(arr[1]) > date.getActualMaximum(Calendar.DAY_OF_MONTH))
         return false;
      if (arr.length > 3
         && (Integer.parseInt(arr[3]) > 23 || Integer.parseInt(arr[4]) > 59 || Integer.parseInt(arr[5]) > 59))
         return false;
      return true;
View Full Code Here

  /**
   * This thread starts here.
   */
  public void run()
  {
    GregorianCalendar prevKeepAliveTime = new GregorianCalendar();

    while(true)
    {
      if(listener == null)
      {
        try
        {
          Thread.sleep(200);
        }
        catch (InterruptedException e)
        {
        }
        continue;
      }

      // check for I/O errors
      if(IOError != null)
      {
        if(reader != null)
          reader.stopReading();

        if(writer != null)
          writer.stopWriting();

        try
        {
          conn.close();
        }
        catch(IOException e)
        {
        }

        IOError = null;
        reader = null;
        writer = null;

        listener.disconnected(this);
      }

      // we are sending keep alive packets once in a minute
      // to keep the Yahoo connection up.
      GregorianCalendar now = new GregorianCalendar();
      prevKeepAliveTime.add(GregorianCalendar.SECOND, 59);
      if(now.after(prevKeepAliveTime))
      {
        Packet pack = new Packet(SERVICE_PING, STATUS_AVAILABLE, sessionID);
        sendToWriterThread(pack);

        prevKeepAliveTime = now;
View Full Code Here

   */
  protected final long[] Lunar(int y, int m) {
    long[] nongDate = new long[7];
    int i = 0, temp = 0, leap = 0;
    //Date baseDate = new Date(1900, 1, 31);
    Date baseDate = new GregorianCalendar(1900+1900,1,31).getTime();
    //Date objDate = new Date(y, m, 1);
    Date objDate = new GregorianCalendar(y+1900,m,1).getTime();
    long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;
    if (y < 2000)
      offset += year19[m - 1];
    if (y > 2000)
      offset += year20[m - 1];
View Full Code Here

  final public static long[] calElement(int y, int m, int d)
  {
    long[] nongDate = new long[7];
    int i = 0, temp = 0, leap = 0;
    //Date baseDate = new Date(0, 0, 31);
    Date baseDate = new GregorianCalendar(0+1900,0,31).getTime();
    //Date objDate = new Date(y - 1900, m - 1, d);
    Date objDate = new GregorianCalendar(y,m-1,d).getTime();
    long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;
    nongDate[5] = offset + 40;
    nongDate[4] = 14;

    for (i = 1900; i < 2050 && offset > 0; i++) {
View Full Code Here

    position++; // skip '.'
    int ms1 = dateString.charAt(position++) - '0';
    int ms2 = dateString.charAt(position++) - '0';
    int ms3 = dateString.charAt(position++) - '0';
    int msecs = 100 * ms1 + 10 * ms2 + ms3;
    Calendar resultCalendar = new GregorianCalendar(year, month - 1, day,
        hour, minutes, secs);
    resultCalendar.setTimeZone(utcTZ);
    long timeInMillis = resultCalendar.getTimeInMillis() + msecs;
    char tzd1 = dateString.charAt(position++);
    if (tzd1 != 'Z') {
      int htz1 = dateString.charAt(position++) - '0';
      int htz2 = dateString.charAt(position++) - '0';
      int hourtz = 10 * htz1 + htz2;
View Full Code Here

     * @return a <CODE>String</CODE> with the error description or <CODE>null</CODE>
     * if no error
     */   
    public static String verifyCertificate(X509Certificate cert, Collection crls, Calendar calendar) {
        if (calendar == null)
            calendar = new GregorianCalendar();
        if (cert.hasUnsupportedCriticalExtension())
            return "Has unsupported critical extension";
        try {
            cert.checkValidity(calendar.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.