Example usage for java.util GregorianCalendar add

List of usage examples for java.util GregorianCalendar add

Introduction

In this page you can find the example usage for java.util GregorianCalendar add.

Prototype

@Override
public void add(int field, int amount) 

Source Link

Document

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

Usage

From source file:org.geosdi.geoplatform.services.GPPublisherBasicServiceImpl.java

private void addTifCleanerJob(String userWorkspace, String layerName, String filePath) {
    if (GPSharedUtils.isEmpty(userWorkspace) || GPSharedUtils.isEmpty(layerName)) {
        throw new IllegalArgumentException(
                "The workspace: " + userWorkspace + " or the layerName: " + layerName + " are null");
    }// w  ww  .  ja v a2  s  . c  om
    TriggerKey triggerKey = new TriggerKey(userWorkspace + ":" + layerName, PublisherScheduler.PUBLISHER_GROUP);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(Calendar.MINUTE, 30);
    Trigger trigger = TriggerBuilder.newTrigger().forJob(this.scheduler.getCleanerJobTifDetail())
            .withIdentity(triggerKey).withDescription("Runs after 30 minutes").startAt(calendar.getTime())
            .withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule()
                    .withMisfireHandlingInstructionFireAndProceed())
            .build();
    trigger.getJobDataMap().put(PublishUtility.USER_WORKSPACE, userWorkspace);
    trigger.getJobDataMap().put(PublishUtility.FILE_NAME, layerName);
    trigger.getJobDataMap().put(PublishUtility.FILE_PATH, filePath);
    trigger.getJobDataMap().put(PublishUtility.PUBLISHER_SERVICE, this);
    this.scheduleTrigger(triggerKey, trigger);
}

From source file:org.geosdi.geoplatform.services.GPPublisherBasicServiceImpl.java

private void addShpCleanerJob(String userWorkspace, String layerName, String filePath) {
    if (GPSharedUtils.isEmpty(userWorkspace) || GPSharedUtils.isEmpty(layerName)) {
        throw new IllegalArgumentException(
                "The workspace: " + userWorkspace + " or the layerName: " + layerName + " are null");
    }/*from  w ww  .ja v  a  2  s  . co m*/
    TriggerKey triggerKey = new TriggerKey(userWorkspace + ":" + layerName, PublisherScheduler.PUBLISHER_GROUP);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(Calendar.MINUTE, 30);
    Trigger trigger = TriggerBuilder.newTrigger().forJob(this.scheduler.getCleanerJobShpDetail())
            .withIdentity(triggerKey).withDescription("Runs after 30 minutes").startAt(calendar.getTime())
            .withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule()
                    .withMisfireHandlingInstructionFireAndProceed())
            .build();
    trigger.getJobDataMap().put(PublishUtility.USER_WORKSPACE, userWorkspace);
    trigger.getJobDataMap().put(PublisherShpCleanerJob.LAYER_NAME, layerName);
    trigger.getJobDataMap().put(PublishUtility.FILE_PATH, filePath);
    trigger.getJobDataMap().put(PublishUtility.PUBLISHER_SERVICE, this);
    this.scheduleTrigger(triggerKey, trigger);
}

From source file:org.webical.test.web.component.WeekViewPanelTest.java

public void testWeekUse() throws WebicalException {
    MockCalendarManager mockCalendarManager = (MockCalendarManager) annotApplicationContextMock
            .getBean("calendarManager");
    Calendar calendar1 = mockCalendarManager.getCalendarById("1");

    MockEventManager mockEventManager = new MockEventManager();
    annotApplicationContextMock.putBean("eventManager", mockEventManager);

    SimpleDateFormat dateFormat = new SimpleDateFormat(
            WebicalSession.getWebicalSession().getUserSettings().getTimeFormat(), getTestSession().getLocale());

    final GregorianCalendar currentDate = CalendarUtils.newTodayCalendar(getFirstDayOfWeek());

    // All events for this week
    List<Event> allEvents = new ArrayList<Event>();

    Date midWeek = CalendarUtils.getFirstDayOfWeek(currentDate.getTime(), getFirstDayOfWeek());
    midWeek = CalendarUtils.addDays(midWeek, 3);

    /* CREATE EVENTS TO RENDER */
    GregorianCalendar cal = CalendarUtils.duplicateCalendar(currentDate);

    // Add a normal event this week
    Event event = new Event();
    event.setUid("e1");
    event.setCalendar(calendar1);/*from  www .ja  v  a2s  .  c o m*/
    event.setSummary("Normal Event Description");
    event.setLocation("Normal Event Location");
    event.setDescription("Event e1");
    cal.setTime(midWeek);
    cal.set(GregorianCalendar.HOUR_OF_DAY, 12);
    event.setDtStart(cal.getTime());
    cal.add(GregorianCalendar.HOUR_OF_DAY, 2);
    event.setDtEnd(cal.getTime());
    log.debug(
            "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd());
    allEvents.add(event);
    mockEventManager.storeEvent(event);

    // Add a short recurring event, starting Tuesday, ending Friday
    event = new Event();
    event.setUid("e2");
    event.setCalendar(calendar1);
    event.setSummary("Recurring Event Yesterday");
    event.setLocation("Recurring Event Location");
    event.setDescription("Event e2");
    cal.setTime(midWeek);
    cal.set(GregorianCalendar.HOUR_OF_DAY, 15);
    cal.add(GregorianCalendar.DAY_OF_MONTH, -1);
    event.setDtStart(cal.getTime());
    cal.add(GregorianCalendar.HOUR_OF_DAY, 3);
    cal.add(GregorianCalendar.DAY_OF_MONTH, 3);
    event.setDtEnd(cal.getTime());
    RecurrenceUtil.setRecurrenceRule(event,
            new Recurrence(Recurrence.DAILY, 1, CalendarUtils.getEndOfDay(cal.getTime())));
    log.debug(
            "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd());
    allEvents.add(event);
    mockEventManager.storeEvent(event);

    // Add a long recurring event, starting last month, ending next month
    event = new Event();
    event.setUid("e3");
    event.setCalendar(calendar1);
    event.setSummary("Recurring Event Last Month");
    event.setLocation("Recurring Event Location");
    event.setDescription("Event e3");
    cal.setTime(midWeek);
    cal.set(GregorianCalendar.HOUR_OF_DAY, 9);
    cal.add(GregorianCalendar.WEEK_OF_YEAR, -1);
    event.setDtStart(cal.getTime());
    cal.add(GregorianCalendar.HOUR_OF_DAY, 2);
    cal.add(GregorianCalendar.WEEK_OF_YEAR, 3);
    event.setDtEnd(cal.getTime());
    RecurrenceUtil.setRecurrenceRule(event,
            new Recurrence(Recurrence.DAILY, 1, CalendarUtils.getEndOfDay(cal.getTime())));
    log.debug(
            "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd());
    allEvents.add(event);
    mockEventManager.storeEvent(event);

    // Add a (pseudo) all day event, starting Monday midnight, ending Tuesday 00:00 hours
    event = new Event();
    event.setUid("e4");
    event.setCalendar(calendar1);
    event.setSummary("Pseudo All Day Event");
    event.setLocation("All Day Event Location");
    event.setDescription("Starting Monday 00:00 hours, ending Tuesday 00:00 hours");
    cal.setTime(midWeek);
    cal.add(GregorianCalendar.DAY_OF_MONTH, -2);
    cal.set(GregorianCalendar.HOUR_OF_DAY, 0);
    cal.set(GregorianCalendar.MINUTE, 0);
    cal.set(GregorianCalendar.SECOND, 0);
    cal.set(GregorianCalendar.MILLISECOND, 0);
    event.setDtStart(cal.getTime());
    cal.add(GregorianCalendar.DAY_OF_MONTH, 1);
    event.setDtEnd(cal.getTime());
    log.debug(
            "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd());
    allEvents.add(event);
    mockEventManager.storeEvent(event);

    // Add a long event this week starting Friday 14.00 hours and ending Saturday 16.00 hours
    event = new Event();
    event.setUid("e5");
    event.setCalendar(calendar1);
    event.setSummary("Long Event Description");
    event.setLocation("Long Event Location");
    event.setDescription("Event e5");
    cal.setTime(midWeek);
    cal.add(GregorianCalendar.DAY_OF_MONTH, 2);
    cal.set(GregorianCalendar.HOUR_OF_DAY, 14);
    cal.set(GregorianCalendar.MINUTE, 0);
    event.setDtStart(cal.getTime());
    cal.add(GregorianCalendar.DAY_OF_MONTH, 1);
    cal.add(GregorianCalendar.HOUR_OF_DAY, 2);
    event.setDtEnd(cal.getTime());
    log.debug(
            "Adding event: " + event.getDescription() + " -> " + event.getDtStart() + " - " + event.getDtEnd());
    allEvents.add(event);
    mockEventManager.storeEvent(event);

    // Create test page with a WeekViewPanel
    wicketTester.startPage(new ITestPageSource() {
        private static final long serialVersionUID = 1L;

        public Page getTestPage() {
            return new PanelTestPage(new WeekViewPanel(PanelTestPage.PANEL_MARKUP_ID, 7, currentDate) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onAction(IAction action) {
                    /* NOTHING TO DO */ }
            });
        }
    });

    // Basic assertions
    wicketTester.assertRenderedPage(PanelTestPage.class);
    wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID, WeekViewPanel.class);

    // Set the correct dates to find the first and last day of the week

    // Assert number of days rendered
    GregorianCalendar weekFirstDayCalendar = CalendarUtils.duplicateCalendar(currentDate);
    weekFirstDayCalendar.setTime(CalendarUtils.getFirstDayOfWeek(currentDate.getTime(), getFirstDayOfWeek()));
    // Assert the first day in the view
    wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID + ":weekColumnRepeater:day"
            + weekFirstDayCalendar.get(GregorianCalendar.DAY_OF_YEAR), WeekDayPanel.class);

    GregorianCalendar weekLastDayCalendar = CalendarUtils.duplicateCalendar(currentDate);
    weekLastDayCalendar.setTime(CalendarUtils.getLastDayOfWeek(currentDate.getTime(), getFirstDayOfWeek()));
    // Assert the last day in the view
    wicketTester.assertComponent(PanelTestPage.PANEL_MARKUP_ID + ":weekColumnRepeater:day"
            + weekLastDayCalendar.get(GregorianCalendar.DAY_OF_YEAR), WeekDayPanel.class);

    // Events for days in this week
    List<Event> dayEvents = new ArrayList<Event>();
    // Assert weekday events
    GregorianCalendar weekCal = CalendarUtils.duplicateCalendar(currentDate);
    weekCal.setTime(CalendarUtils.getFirstDayOfWeek(currentDate.getTime(), getFirstDayOfWeek()));
    for (int i = 0; i < 7; ++i) {
        WeekDayPanel weekDayEventsListView = (WeekDayPanel) wicketTester.getLastRenderedPage()
                .get(PanelTestPage.PANEL_MARKUP_ID + ":weekColumnRepeater:day"
                        + weekCal.get(GregorianCalendar.DAY_OF_YEAR));
        int weekDay = getFirstDayOfWeek() + weekCal.get(GregorianCalendar.DAY_OF_WEEK) - 1; // First day of the week is 1
        if (weekDay > 7)
            weekDay = 1;
        switch (weekDay) {
        case GregorianCalendar.SUNDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(2)); // e3
            break;
        case GregorianCalendar.MONDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(2)); // e3
            dayEvents.add(allEvents.get(3)); // e4
            break;
        case GregorianCalendar.TUESDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(1)); // e2
            dayEvents.add(allEvents.get(2)); // e3
            break;
        case GregorianCalendar.WEDNESDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(0)); // e1
            dayEvents.add(allEvents.get(1)); // e2
            dayEvents.add(allEvents.get(2)); // e3
            break;
        case GregorianCalendar.THURSDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(1)); // e2
            dayEvents.add(allEvents.get(2)); // e3
            break;
        case GregorianCalendar.FRIDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(1)); // e2
            dayEvents.add(allEvents.get(2)); // e3
            dayEvents.add(allEvents.get(4)); // e5
            break;
        case GregorianCalendar.SATURDAY:
            dayEvents.clear();
            dayEvents.add(allEvents.get(2)); // e3
            dayEvents.add(allEvents.get(4)); // e5
            break;
        }
        String path = weekDayEventsListView.getPageRelativePath() + ":eventItem";
        wicketTester.assertListView(path, dayEvents);

        ListView listView = (ListView) wicketTester.getComponentFromLastRenderedPage(path);
        Iterator<?> lvIt = listView.iterator();
        while (lvIt.hasNext()) {
            ListItem item = (ListItem) lvIt.next();
            Event evt = (Event) item.getModelObject();
            List<?> bhvs = item.getBehaviors();
            if (evt.getUid().equals("e4"))
                assertEquals(1, bhvs.size()); // only e4 is an all day event
            else
                assertEquals(0, bhvs.size());

            if (evt.getUid().equals("e5")) { // e5: Fri 14:00 to Sat 16:00
                String timePath = item.getPageRelativePath() + ":eventLink:eventTime";
                String timeLabelText = null;
                if (weekDay == GregorianCalendar.FRIDAY)
                    timeLabelText = dateFormat.format(evt.getDtStart());
                else
                    timeLabelText = dateFormat.format(midWeek); // time 00:00
                wicketTester.assertLabel(timePath, timeLabelText);
            }
        }

        weekCal.add(GregorianCalendar.DAY_OF_WEEK, 1);
    }
}

From source file:org.agnitas.util.AgnUtils.java

/**
 * Checks if date is in future.//  w  w  w .ja va 2  s .co  m
 *
 * @param aDate Checked date.
 */
public static boolean isDateInFuture(Date aDate) {
    boolean result = false;
    GregorianCalendar aktCal = new GregorianCalendar();
    GregorianCalendar tmpCal = new GregorianCalendar();

    tmpCal.setTime(aDate);
    aktCal.add(GregorianCalendar.MINUTE, 5); // look five minutes in future ;-)
    if (aktCal.before(tmpCal)) {
        result = true;
    }

    return result;
}

From source file:com.joey.software.MoorFLSI.RepeatImageTextReader.java

public void loadTextData(File file) {
    try {/*from  w  w w.  jav a2  s . c  o m*/
        RandomAccessFile in = new RandomAccessFile(file, "r");

        // Skip header
        in.readLine();
        in.readLine();
        in.readLine();

        // Skip Subject Information
        in.readLine();
        in.readLine();
        in.readLine();
        in.readLine();
        in.readLine();
        in.readLine();
        String startTimeInput = in.readLine();
        String commentsInput = in.readLine();

        String data = in.readLine();
        while (!data.startsWith("2) System Configuration")) {
            commentsInput += data;
            data = in.readLine();
        }
        // System configuration

        // in.readLine();
        in.readLine();
        String timeCounstantInput = in.readLine();
        String cameraGainInput = in.readLine();
        String exposureTimeInput = in.readLine();
        in.readLine();
        in.readLine();
        in.readLine();
        String resolutionInput = in.readLine();

        // Time Data
        in.readLine();
        String timeDataInput = in.readLine();
        String totalImagesInput = in.readLine();
        in.readLine();
        in.readLine();
        // in.readLine();
        // System.out.println(in.readLine());
        // in.readLine();

        // Parse important Size

        high = (new Scanner(resolutionInput.split(":")[1])).nextInt();
        wide = (new Scanner(resolutionInput.split(",")[1])).nextInt();
        int tot = 1;
        try {
            tot = (new Scanner(totalImagesInput.split(":")[1])).nextInt();
        } catch (Exception e) {

        }
        System.out.println(wide + "," + high);
        // Parse timeInformation
        SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss (dd/MM/yy)");
        Date startTime = null;
        try {
            startTime = format.parse(startTimeInput.split(": ")[1]);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        String[] frameTimeData = timeDataInput.split("information:")[1].split(",");

        Date[] timeInfo = new Date[tot];
        for (int i = 0; i < frameTimeData.length - 1; i++) {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTime(startTime);
            String dat = (frameTimeData[i]);
            String[] timeVals = dat.split(":");

            int hour = Integer.parseInt(StringOperations.removeNonNumber(timeVals[0]));
            int min = Integer.parseInt(StringOperations.removeNonNumber(timeVals[1]));
            int sec = Integer.parseInt(StringOperations.removeNonNumber(timeVals[2]));
            int msec = Integer.parseInt(StringOperations.removeNonNumber(timeVals[3]));

            cal.add(Calendar.HOUR_OF_DAY, hour);
            cal.add(Calendar.MINUTE, min);
            cal.add(Calendar.SECOND, sec);
            cal.add(Calendar.MILLISECOND, msec);
            timeInfo[i] = cal.getTime();
        }

        // Parse Image Data
        /*
         * Close Random access file and switch to scanner first store pos
         * then move to correct point.
         */
        long pos = in.getFilePointer();
        in.close();

        FileInputStream fIn = new FileInputStream(file);
        fIn.skip(pos);

        BufferedInputStream bIn = new BufferedInputStream(fIn);
        Scanner sIn = new Scanner(bIn);

        short[][][] holder = new short[tot][wide][high];

        JFrame f = new JFrame();
        f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        StatusBarPanel stat = new StatusBarPanel();
        stat.setMaximum(high);
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(stat, BorderLayout.CENTER);
        f.setSize(200, 60);
        f.setVisible(true);

        for (int i = 0; i < tot; i++) {
            // Skip over the heading values
            stat.setStatusMessage("Loading " + i + " of " + tot);
            sIn.useDelimiter("\n");
            sIn.next();
            sIn.next();
            sIn.next();
            if (i != 0) {
                sIn.next();
            }
            sIn.reset();
            for (int y = 0; y < high; y++) {
                stat.setValue(y);
                sIn.nextInt();
                for (int x = 0; x < wide; x++) {
                    holder[i][x][y] = sIn.nextShort();
                }

            }
            addData(timeInfo[i], holder[i]);
        }

        // FrameFactroy.getFrame(new DynamicRangeImage(data[0]));
        // Start Image Data

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.oscarehr.web.Cds4ReportUIBean.java

public String getDateRangeForDisplay() {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    GregorianCalendar displayEndDate = (GregorianCalendar) endDate.clone();
    displayEndDate.add(GregorianCalendar.MONTH, -1);
    return (StringEscapeUtils.escapeHtml(simpleDateFormat.format(startDate.getTime()) + " to "
            + simpleDateFormat.format(displayEndDate.getTime()) + " (inclusive)"));
}

From source file:org.mifos.accounts.loan.struts.action.LoanAccountAction.java

/**
 * Resolve repayment start date according to given disbursement date
 * <p/>//from w  ww . ja v  a2s .  c o m
 * The resulting date equates to the disbursement date plus MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY: e.g.
 * If disbursement date is 18 June 2008, and MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY is 1 then the
 * repayment start date would be 19 June 2008
 *
 * @return Date repaymentStartDate
 * @throws PersistenceException
 */
private Date resolveRepaymentStartDate(final Date disbursementDate) {
    int minDaysInterval = configurationPersistence
            .getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);

    final GregorianCalendar repaymentStartDate = new GregorianCalendar();
    repaymentStartDate.setTime(disbursementDate);
    repaymentStartDate.add(Calendar.DAY_OF_WEEK, minDaysInterval);
    return repaymentStartDate.getTime();
}

From source file:com.nadmm.airports.ActivityBase.java

public void showAirportTitle(Cursor c) {
    View root = findViewById(R.id.airport_title_layout);
    TextView tv = (TextView) root.findViewById(R.id.facility_name);
    String code = c.getString(c.getColumnIndex(Airports.ICAO_CODE));
    if (code == null || code.length() == 0) {
        code = c.getString(c.getColumnIndex(Airports.FAA_CODE));
    }//w w  w .j  ava 2  s .c  o m
    String tower = c.getString(c.getColumnIndex(Airports.TOWER_ON_SITE));
    int color = tower.equals("Y") ? Color.rgb(48, 96, 144) : Color.rgb(128, 72, 92);
    tv.setTextColor(color);
    String name = c.getString(c.getColumnIndex(Airports.FACILITY_NAME));
    String siteNumber = c.getString(c.getColumnIndex(Airports.SITE_NUMBER));
    String type = DataUtils.decodeLandingFaclityType(siteNumber);
    tv.setText(String.format(Locale.US, "%s %s", name, type));
    tv = (TextView) root.findViewById(R.id.facility_id);
    tv.setTextColor(color);
    tv.setText(code);
    tv = (TextView) root.findViewById(R.id.facility_info);
    String city = c.getString(c.getColumnIndex(Airports.ASSOC_CITY));
    String state = c.getString(c.getColumnIndex(States.STATE_NAME));
    if (state == null) {
        state = c.getString(c.getColumnIndex(Airports.ASSOC_COUNTY));
    }
    tv.setText(String.format(Locale.US, "%s, %s", city, state));
    tv = (TextView) root.findViewById(R.id.facility_info2);
    int distance = c.getInt(c.getColumnIndex(Airports.DISTANCE_FROM_CITY_NM));
    String dir = c.getString(c.getColumnIndex(Airports.DIRECTION_FROM_CITY));
    String status = c.getString(c.getColumnIndex(Airports.STATUS_CODE));
    tv.setText(String.format(Locale.US, "%s, %d miles %s of city center", DataUtils.decodeStatus(status),
            distance, dir));
    tv = (TextView) root.findViewById(R.id.facility_info3);
    float elev_msl = c.getFloat(c.getColumnIndex(Airports.ELEVATION_MSL));
    int tpa_agl = c.getInt(c.getColumnIndex(Airports.PATTERN_ALTITUDE_AGL));
    String est = "";
    if (tpa_agl == 0) {
        tpa_agl = 1000;
        est = " (est.)";
    }
    tv.setText(String.format(Locale.US, "%s MSL elev. - %s MSL TPA %s", FormatUtils.formatFeet(elev_msl),
            FormatUtils.formatFeet(elev_msl + tpa_agl), est));

    String s = c.getString(c.getColumnIndex(Airports.EFFECTIVE_DATE));
    GregorianCalendar endDate = new GregorianCalendar(Integer.valueOf(s.substring(6)),
            Integer.valueOf(s.substring(3, 5)), Integer.valueOf(s.substring(0, 2)));
    // Calculate end date of the 56-day cycle
    endDate.add(GregorianCalendar.DAY_OF_MONTH, 56);
    Calendar now = Calendar.getInstance();
    if (now.after(endDate)) {
        // Show the expired warning
        tv = (TextView) root.findViewById(R.id.expired_label);
        tv.setVisibility(View.VISIBLE);
    }

    CheckBox cb = (CheckBox) root.findViewById(R.id.airport_star);
    cb.setChecked(mDbManager.isFavoriteAirport(siteNumber));
    cb.setTag(siteNumber);
    cb.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            CheckBox cb = (CheckBox) v;
            String siteNumber = (String) cb.getTag();
            if (cb.isChecked()) {
                mDbManager.addToFavoriteAirports(siteNumber);
                Toast.makeText(ActivityBase.this, "Added to favorites list", Toast.LENGTH_LONG).show();
            } else {
                mDbManager.removeFromFavoriteAirports(siteNumber);
                Toast.makeText(ActivityBase.this, "Removed from favorites list", Toast.LENGTH_LONG).show();
            }
        }

    });

    ImageView iv = (ImageView) root.findViewById(R.id.airport_map);
    String lat = c.getString(c.getColumnIndex(Airports.REF_LATTITUDE_DEGREES));
    String lon = c.getString(c.getColumnIndex(Airports.REF_LONGITUDE_DEGREES));
    if (lat.length() > 0 && lon.length() > 0) {
        iv.setTag("geo:" + lat + "," + lon + "?z=16");
        iv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                String tag = (String) v.getTag();
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tag));
                startActivity(intent);
            }

        });
    } else {
        iv.setVisibility(View.GONE);
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_080_SubscriptionIntegrationTest.java

/**
 * invalid expiration time/*  www  .ja  va 2 s . co m*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_2() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_2");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    // invalid expiration time
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.DATE, -1);
    XMLGregorianCalendar newXMLGregorianCalendar = df.newXMLGregorianCalendar(gcal);

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(newXMLGregorianCalendar);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.oscarehr.web.Cds4ReportUIBean.java

private List<CdsHospitalisationDays> getHopitalisationDays2YearsBeforeAdmission(CdsClientForm form) {
    Admission admission = admissionMap.get(form.getAdmissionId());

    GregorianCalendar startBound = (GregorianCalendar) admission.getAdmissionCalendar().clone();
    startBound.add(GregorianCalendar.YEAR, -2); // 2 years prior to admission
    // materialise results
    startBound.getTimeInMillis();//ww  w.j a  v  a2 s  . co m

    return (getHopitalisationDaysDuringPeriod(form, startBound, admission.getAdmissionCalendar()));
}