Example usage for java.util Calendar DAY_OF_MONTH

List of usage examples for java.util Calendar DAY_OF_MONTH

Introduction

In this page you can find the example usage for java.util Calendar DAY_OF_MONTH.

Prototype

int DAY_OF_MONTH

To view the source code for java.util Calendar DAY_OF_MONTH.

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:es.tekniker.framework.ktek.util.Utils.java

public static long getTimeinMillis4FullDateTimeGMT(int year, int month, int day, int hours, int minutes,
        int seconds) {
    Calendar c = getCalendarGMT();

    c.set(Calendar.YEAR, year);//from www.  j  a v a2 s . c  om
    c.set(Calendar.MONTH, month);
    c.set(Calendar.DAY_OF_MONTH, day);

    c.set(Calendar.HOUR_OF_DAY, hours);
    c.set(Calendar.MINUTE, minutes);
    c.set(Calendar.SECOND, seconds);

    System.out.println("New Time: " + c.getTime());

    long timeinmillis = c.getTimeInMillis();
    System.out.println(" system time in millis " + timeinmillis);

    return timeinmillis;
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static boolean isSameDay(Date first, Date second) {
    if ((first == null || second == null) && !first.equals(second)) {
        return false;
    }/*from w w w .  j a  v a 2s.co  m*/
    Date firstDay = DateUtils.truncate(first, Calendar.DAY_OF_MONTH);
    Date secondDay = DateUtils.truncate(second, Calendar.DAY_OF_MONTH);
    return firstDay.equals(secondDay);
}

From source file:com.sirma.itt.emf.time.ISO8601DateFormat.java

/**
 * Format calendar instance into ISO format.
 * /*from   w w w .j av  a  2s  . c o m*/
 * @param calendar
 *            the calendar instance to format
 * @return the ISO formatted string
 */
public static String format(Calendar calendar) {
    if (calendar == null) {
        return null;
    }

    StringBuilder formatted = new StringBuilder(28);
    padInt(formatted, calendar.get(Calendar.YEAR), 4);
    formatted.append('-');
    padInt(formatted, calendar.get(Calendar.MONTH) + 1, 2);
    formatted.append('-');
    padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), 2);
    formatted.append('T');
    padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), 2);
    formatted.append(':');
    padInt(formatted, calendar.get(Calendar.MINUTE), 2);
    formatted.append(':');
    padInt(formatted, calendar.get(Calendar.SECOND), 2);
    formatted.append('.');
    padInt(formatted, calendar.get(Calendar.MILLISECOND), 3);

    TimeZone tz = calendar.getTimeZone();
    int offset = tz.getOffset(calendar.getTimeInMillis());
    formatted.append(getTimeZonePadding(offset));

    return formatted.toString();
}

From source file:ch.cyberduck.core.ftp.parser.FreeboxFTPEntryParserTest.java

@Test
public void testParse() {
    FTPFile parsed;/*  w w  w.  j  av a2 s.  co  m*/

    parsed = parser.parseFTPEntry(
            "-rw-r--r--   1  freebox  freebox 2064965868 Apr 15 21:17 M6 - Capital 15-04-2007 21h37 1h40m.ts");
    assertNotNull(parsed);
    assertEquals(parsed.getName(), "M6 - Capital 15-04-2007 21h37 1h40m.ts");
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals("freebox", parsed.getUser());
    assertEquals("freebox", parsed.getGroup());
    assertEquals(2064965868, parsed.getSize());
    assertEquals(Calendar.APRIL, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));

    parsed = parser.parseFTPEntry(
            "-rw-r--r--   1  freebox  freebox 75906880 Sep 08 06:33 Direct 8 - Gym direct - 08-09-2007 08h30 1h08m.ts");
    assertNotNull(parsed);
    assertEquals("Direct 8 - Gym direct - 08-09-2007 08h30 1h08m.ts", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals("freebox", parsed.getUser());
    assertEquals("freebox", parsed.getGroup());
    assertEquals(75906880, parsed.getSize());
    assertEquals(Calendar.SEPTEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(8, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));

    parsed = parser.parseFTPEntry(
            "-rw-r--r--   1  freebox  freebox 1171138668 May 19 17:20 France 3 national - 19-05-2007 18h15 1h05m.ts");
    assertNotNull(parsed);
    assertEquals("France 3 national - 19-05-2007 18h15 1h05m.ts", parsed.getName());
}

From source file:Controller.Movimientos.generatePDF.java

public void generateAgendaEmpleados() {
    mm = new Model_Movimientos();
    try {/*from   w w  w .  j  av a2s .co  m*/

        Calendar calendar = Calendar.getInstance();
        int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
        int monthOfYear = calendar.get(Calendar.MONTH);
        int year = calendar.get(Calendar.YEAR);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int min = calendar.get(Calendar.MINUTE);
        int sec = calendar.get(Calendar.SECOND);

        Document documento = new Document();//Creamos el documento
        FileOutputStream ficheroPdf = new FileOutputStream("agendaEmpleados" + dayOfMonth + "--" + monthOfYear
                + "--" + year + " " + hour + ";" + min + ";" + sec + ".pdf");//Abrimos el flujo y le asignamos nombre al pdf y su direccion
        PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20);//Instanciamos el documento con el fichero

        documento.open();//Abrimos el documento

        documento.add(new Paragraph("Lista Empleados",
                FontFactory.getFont("Calibri", 30, Font.BOLD, BaseColor.BLACK)));//Le indicamos el tipo de letra, el tamanio, el estilo y el color de la letra
        documento.add(new Paragraph("___________________________"));//Realiza un salto de linea
        Iterator it;
        it = mm.getCrews().iterator();
        while (it.hasNext()) {
            Crew c = (Crew) it.next();
            System.out.println("" + c.getEmail().toString());
            documento.add(new Paragraph(""));
            //Le decimos que nos imprima el Dni, Nombre y Apellidos del cliente, contenidos en el objeto Cliente y le indicamos el tipo de letra, tamanio, estilo y color de la letra
            documento.add(new Paragraph("Nombre: " + c.getName(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Apellidos: " + c.getSurname(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Email: " + c.getEmail(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Telfono: " + c.getPhoneNumber(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Nickname: " + c.getNickname(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Contrasea: " + c.getPassword(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph("Puesto: " + c.getRole(),
                    FontFactory.getFont("Calibri", 20, Font.BOLD, BaseColor.BLACK)));
            documento.add(new Paragraph(" "));
            documento.add(new Paragraph(" "));
            documento.add(new Paragraph(
                    "______________________________________________________________________________"));
        }

        documento.close();//Cerramos el flujo con el documento
        JOptionPane.showMessageDialog(null, "Se ha creado agenda de Empleados.");

    } catch (DocumentException ex) {
        Logger.getLogger(generatePDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(generatePDF.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.swiftcorp.portal.common.util.CalendarUtils.java

public static Calendar addDayToCalendar(Calendar calendar, int day) {
    calendar.add(Calendar.DAY_OF_MONTH, day);

    return calendar;
}

From source file:cn.vlabs.duckling.aone.infrastructure.repository.MessageDAOTest.java

@Test
public void testCreateMessage() {
    Date now = new Date();
    Date today = DateUtils.truncate(now, Calendar.DAY_OF_MONTH);
    Date tommrow = DateUtils.truncate(DateUtils.addDays(now, 1), Calendar.DAY_OF_MONTH);

    MessageBody body = createMessage(now);
    Publisher publisher = createPublisher(Publisher.PAGE_TYPE);

    int messageId = md.createMessage(tid, body, publisher, new String[] { "liji@cnic.cn", "xiejj@cnic.cn" });
    try {//w  w w .ja  v  a2  s  .  co m

        List<Message> message = md.getMessage(tid, "xiejj@cnic.cn", today, tommrow);

        assertNotNull("Must be one message", message);
        assertEquals("Only one message", 1, message.size());
        assertEquals("Title expected", "New message from column A", message.get(0).getBody().getTitle());
    } finally {
        md.removeMessage(messageId);
    }
}

From source file:au.com.jwatmuff.eventmanager.Main.java

/**
 * Main method./*w  ww . j  ava 2s . c om*/
 */
public static void main(String args[]) {
    LogUtils.setupUncaughtExceptionHandler();

    /* Set timeout for RMI connections - TODO: move to external file */
    System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", "2000");
    updateRmiHostName();

    /*
     * Set up menu bar for Mac
     */
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Event Manager");

    /*
     * Set look and feel to 'system' style
     */
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.info("Failed to set system look and feel");
    }

    /*
     * Set workingDir to a writable folder for storing competitions, settings etc.
     */
    String applicationData = System.getenv("APPDATA");
    if (applicationData != null) {
        workingDir = new File(applicationData, "EventManager");
        if (workingDir.exists() || workingDir.mkdirs()) {
            // redirect logging to writable folder
            LogUtils.reconfigureFileAppenders("log4j.properties", workingDir);
        } else {
            workingDir = new File(".");
        }
    }

    // log version for debugging
    log.info("Running version: " + VISIBLE_VERSION + " (Internal: " + VERSION + ")");

    /*
     * Copy license if necessary
     */
    File license1 = new File("license.lic");
    File license2 = new File(workingDir, "license.lic");
    if (license1.exists() && !license2.exists()) {
        try {
            FileUtils.copyFile(license1, license2);
        } catch (IOException e) {
            log.warn("Failed to copy license from " + license1 + " to " + license2, e);
        }
    }
    if (license1.exists() && license2.exists()) {
        if (license1.lastModified() > license2.lastModified()) {
            try {
                FileUtils.copyFile(license1, license2);
            } catch (IOException e) {
                log.warn("Failed to copy license from " + license1 + " to " + license2, e);
            }
        }
    }

    /*
     * Check if run lock exists, if so ask user if it is ok to continue
     */
    if (!obtainRunLock(false)) {
        int response = JOptionPane.showConfirmDialog(null,
                "Unable to obtain run-lock.\nPlease ensure that no other instances of EventManager are running before continuing.\nDo you wish to continue?",
                "Run-lock detected", JOptionPane.YES_NO_OPTION);
        if (response == JOptionPane.YES_OPTION)
            obtainRunLock(true);
        else
            System.exit(0);
    }

    try {
        LoadWindow loadWindow = new LoadWindow();
        loadWindow.setVisible(true);

        loadWindow.addMessage("Reading settings..");

        /*
         * Read properties from file
         */
        final Properties props = new Properties();
        try {
            Properties defaultProps = PropertiesLoaderUtils
                    .loadProperties(new ClassPathResource("eventmanager.properties"));
            props.putAll(defaultProps);
        } catch (IOException ex) {
            log.error(ex);
        }

        props.putAll(System.getProperties());

        File databaseStore = new File(workingDir, "comps");
        int rmiPort = Integer.parseInt(props.getProperty("eventmanager.rmi.port"));

        loadWindow.addMessage("Loading Peer Manager..");
        log.info("Loading Peer Manager");

        ManualDiscoveryService manualDiscoveryService = new ManualDiscoveryService();
        JmDNSRMIPeerManager peerManager = new JmDNSRMIPeerManager(rmiPort, new File(workingDir, "peerid.dat"));
        peerManager.addDiscoveryService(manualDiscoveryService);

        monitorNetworkInterfaceChanges(peerManager);

        loadWindow.addMessage("Loading Database Manager..");
        log.info("Loading Database Manager");

        DatabaseManager databaseManager = new SQLiteDatabaseManager(databaseStore, peerManager);
        LicenseManager licenseManager = new LicenseManager(workingDir);

        loadWindow.addMessage("Loading Load Competition Dialog..");
        log.info("Loading Load Competition Dialog");

        LoadCompetitionWindow loadCompetitionWindow = new LoadCompetitionWindow(databaseManager, licenseManager,
                peerManager);
        loadCompetitionWindow.setTitle(WINDOW_TITLE);

        loadWindow.dispose();
        log.info("Starting Load Competition Dialog");

        while (true) {
            // reset permission checker to use our license
            licenseManager.updatePermissionChecker();

            GUIUtils.runModalJFrame(loadCompetitionWindow);

            if (loadCompetitionWindow.getSuccess()) {
                DatabaseInfo info = loadCompetitionWindow.getSelectedDatabaseInfo();

                if (!databaseManager.checkLock(info.id)) {
                    String message = "EventManager did not shut down correctly the last time this competition was open. To avoid potential data corruption, you are advised to take the following steps:\n"
                            + "1) Do NOT open this competition\n" + "2) Create a backup of this competition\n"
                            + "3) Delete the competition from this computer\n"
                            + "4) If possible, reload this competition from another computer on the network\n"
                            + "5) Alternatively, you may manually load the backup onto all computers on the network, ensuring the 'Preserve competition ID' option is checked.";
                    String title = "WARNING: Potential Data Corruption Detected";

                    int status = JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION,
                            JOptionPane.ERROR_MESSAGE, null,
                            new Object[] { "Cancel (recommended)", "Open anyway" }, "Cancel (recommended)");

                    if (status == 0)
                        continue; // return to load competition window
                }

                SynchronizingWindow syncWindow = new SynchronizingWindow();
                syncWindow.setVisible(true);
                long t = System.nanoTime();
                DistributedDatabase database = databaseManager.activateDatabase(info.id, info.passwordHash);
                long dt = System.nanoTime() - t;
                log.debug(String.format("Initial sync in %dms",
                        TimeUnit.MILLISECONDS.convert(dt, TimeUnit.NANOSECONDS)));
                syncWindow.dispose();

                if (loadCompetitionWindow.isNewDatabase()) {
                    GregorianCalendar calendar = new GregorianCalendar();
                    Date today = calendar.getTime();
                    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
                    calendar.set(Calendar.DAY_OF_MONTH, 31);
                    Date endOfYear = new java.sql.Date(calendar.getTimeInMillis());

                    CompetitionInfo ci = new CompetitionInfo();
                    ci.setName(info.name);
                    ci.setStartDate(today);
                    ci.setEndDate(today);
                    ci.setAgeThresholdDate(endOfYear);
                    //ci.setPasswordHash(info.passwordHash);
                    License license = licenseManager.getLicense();
                    if (license != null) {
                        ci.setLicenseName(license.getName());
                        ci.setLicenseType(license.getType().toString());
                        ci.setLicenseContact(license.getContactPhoneNumber());
                    }
                    database.add(ci);
                }

                // Set PermissionChecker to use database's license type
                String competitionLicenseType = database.get(CompetitionInfo.class, null).getLicenseType();
                PermissionChecker.setLicenseType(LicenseType.valueOf(competitionLicenseType));

                TransactionNotifier notifier = new TransactionNotifier();
                database.setListener(notifier);

                MainWindow mainWindow = new MainWindow();
                mainWindow.setDatabase(database);
                mainWindow.setNotifier(notifier);
                mainWindow.setPeerManager(peerManager);
                mainWindow.setLicenseManager(licenseManager);
                mainWindow.setManualDiscoveryService(manualDiscoveryService);
                mainWindow.setTitle(WINDOW_TITLE);
                mainWindow.afterPropertiesSet();

                TestUtil.setActivatedDatabase(database);

                // show main window (modally)
                GUIUtils.runModalJFrame(mainWindow);

                // shutdown procedures

                // System.exit();

                database.shutdown();
                databaseManager.deactivateDatabase(1500);

                if (mainWindow.getDeleteOnExit()) {
                    for (File file : info.localDirectory.listFiles())
                        if (!file.isDirectory())
                            file.delete();
                    info.localDirectory.deleteOnExit();
                }
            } else {
                // This can cause an RuntimeException - Peer is disconnected
                peerManager.stop();
                System.exit(0);
            }
        }
    } catch (Throwable e) {
        log.error("Error in main function", e);
        String message = e.getMessage();
        if (message == null)
            message = "";
        if (message.length() > 100)
            message = message.substring(0, 97) + "...";
        GUIUtils.displayError(null,
                "An unexpected error has occured.\n\n" + e.getClass().getSimpleName() + "\n" + message);
        System.exit(0);
    }
}

From source file:com.pearson.openideas.cq5.components.utils.ArticleUtils.java

/**
 * This method turns a tagged resource into an article object.
 * /*from w w w . j  a v a2s. c o m*/
 * @param resource
 *            the resource to extract data from
 * @param article
 *            the article object to add data to
 * @param tagManager
 *            the tag manager instance
 * @param indexing
 *            A boolean to indicate whether to include the indexing fields or not.
 * @return the completed/populated article object
 */
public static Article createArticleObject(Resource resource, Article article, TagManager tagManager,
        boolean indexing) {

    List<String> countries = new ArrayList<String>();
    List<String> contributors = new ArrayList<String>();
    List<String> organisations = new ArrayList<String>();
    List<String> keywords = new ArrayList<String>();
    List<String> contributorBiogs = new ArrayList<String>();

    log.debug("Are we indexing? " + indexing);

    Calendar weekAgo = Calendar.getInstance();
    weekAgo.set(weekAgo.get(Calendar.YEAR), weekAgo.get(Calendar.MONTH),
            weekAgo.get(Calendar.DAY_OF_MONTH) - BEFOREDAYS);

    String path = resource.getPath();
    log.debug("path to resource: " + path);
    article.setUrl(StringUtils.substring(path, 0, path.lastIndexOf("/")));
    ValueMap articleMap = resource.getChild("articleBody").adaptTo(ValueMap.class);
    article.setShortSummary(articleMap.get("shortsummary", ""));
    article.setArticleTitle(articleMap.get("articletitle", ""));

    //pull the image from the article
    Image image = new Image(resource.getChild("articleBody").getChild("image"));
    image.setSelector(".img");
    article.setImage(image);

    //also, pull the thumbnail image from the article
    if (resource.getChild("articleBody").getChild("imagethumb") != null) {
        Image thumbnail = new Image(resource.getChild("articleBody").getChild("imagethumb"));
        thumbnail.setSelector(".img");
        log.debug("article thumbnail has an image: " + thumbnail.hasContent());
        article.setThumbnail(thumbnail);
    } else {
        log.debug("no thumbnail, falling back to article image");
        article.setThumbnail(image);
    }

    // second, we'll pull the contributor tags from however many contributor components we have
    Resource leadContribResource = resource.getChild("leadContributor");

    // pull an array of one to get the lead contributor name for rendering
    Tag[] leadContribTags = tagManager.getTags(leadContribResource);
    if (leadContribTags != null && leadContribTags.length > 0) {
        article.setAuthor(leadContribTags[0].getTitle());
    } else {
        log.warn("Article " + article.getArticleTitle() + "has no lead contributor set yet.");
    }

    if (StringUtils.isNotBlank(articleMap.get("newpublishdate", ""))) {
        Date newPubDateObject = null;
        SimpleDateFormat sdf = new SimpleDateFormat(DateFormatEnum.CQDATEFORMAT.getDateFormat());

        try {
            newPubDateObject = sdf.parse(articleMap.get("newpublishdate", ""));
        } catch (ParseException e) {
            log.error("Error parsing date", e);
        }

        if (newPubDateObject != null) {
            String newDateString = new SimpleDateFormat(DateFormatEnum.CLIENTDATEFORMAT.getDateFormat())
                    .format(newPubDateObject);
            article.setPubDate(newDateString);
            article.setPubDateObject(newPubDateObject);
            if (newPubDateObject.after(weekAgo.getTime())) {
                article.setSuitableForEmail(true);
            }

        } else {
            log.warn("new pub date object is null");
        }
    } else {
        log.debug("Trying to parse original date object");
        Date originalPubDateObject = resource.adaptTo(ValueMap.class).get("jcr:created", Date.class);
        log.debug("original pub date: " + originalPubDateObject.toString());
        String originalPublishDateString = new SimpleDateFormat(DateFormatEnum.CLIENTDATEFORMAT.getDateFormat())
                .format(originalPubDateObject);
        article.setPubDate(originalPublishDateString);
        article.setPubDateObject(originalPubDateObject);
        if (originalPubDateObject.after(weekAgo.getTime())) {
            article.setSuitableForEmail(true);
        }
    }

    Tag[] tags = tagManager.getTags(resource);
    for (Tag tagFromPage : tags) {
        String tagPath = tagFromPage.getPath();

        if (tagPath.contains(NamespaceEnum.THEME.getNamespace())) {
            article.setTheme(tagFromPage.getTitle());
        } else if (tagPath.contains(NamespaceEnum.CATEGORY.getNamespace())) {
            article.setCategory(tagFromPage.getTitle());
        } else if (indexing && tagPath.contains(NamespaceEnum.CONTRIBUTOR.getNamespace())) {
            contributors.add(tagFromPage.getTitle());
            contributorBiogs.add(tagFromPage.getDescription());
        } else if (indexing && tagPath.contains(NamespaceEnum.KEYWORD.getNamespace())) {
            keywords.add(tagFromPage.getTitle());
        } else if (indexing && tagPath.contains(NamespaceEnum.ORGANISATION.getNamespace())) {
            organisations.add(tagFromPage.getTitle());
        } else if (indexing && tagPath.contains(NamespaceEnum.COUNTRY.getNamespace())) {
            countries.add(tagFromPage.getTitle());
        }
    }

    if (indexing) {
        article.setContributors(contributors);
        article.setCountries(countries);
        article.setOrganisations(organisations);
        article.setKeywords(keywords);
        article.setContributorBiogs(contributorBiogs);
        article.setCitation(articleMap.get("citation", ""));
        String articleText = articleMap.get("text", "");

        Resource par = resource.getChild("par");

        if (par != null) {
            Iterator<Resource> parResources = par.listChildren();
            while (parResources.hasNext()) {
                Resource parResource = parResources.next();
                ValueMap resourceMap = parResource.adaptTo(ValueMap.class);
                String type = resourceMap.get("sling:resourceType", "");
                if (type.endsWith("articleText")) {
                    articleText += resourceMap.get("text", "");
                }
            }
        }
        article.setArticleText(articleText);
    }
    return article;

}

From source file:net.ceos.project.poi.annotated.bean.SimpleObjectBuilder.java

/**
 * Validate the SimpleObject based on the object build with the method
 * 'buildSimpleObject'//ww  w .j a v a2 s .c  o  m
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateSimpleObject(SimpleObject toValidate) {
    SimpleObject base = buildSimpleObject();

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    Calendar calendarUnmarshal = Calendar.getInstance();
    calendarUnmarshal.setTime(toValidate.getDateAttribute());
    assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR));
    assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH));
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH));
    assertEquals(base.getStringAttribute(), toValidate.getStringAttribute());
    assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute());
    // TODO add new validation below
}