Example usage for java.util Calendar HOUR

List of usage examples for java.util Calendar HOUR

Introduction

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

Prototype

int HOUR

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

Click Source Link

Document

Field number for get and set indicating the hour of the morning or afternoon.

Usage

From source file:com.planit.smsrenta.controladores.VehiculoBean.java

public List<SmsVehiculo> consultarVehiculosDisponible(SmsReservacion reserva, SmsMercado mercado,
        int categoriaServicio) {
    vehiculosListView = new ArrayList<>();
    String ciudadVeh = reserva.getSmsCiudadByIdCiudadInicio().getCiudadNombre();
    String mercadoSeleccionado = mercado.getMercadoNombre();

    Calendar calInicio = Calendar.getInstance();
    calInicio.setTime(reserva.getReservacionHoraInicio());
    calInicio.add(Calendar.HOUR, -1);
    calInicio.add(Calendar.MINUTE, -59);

    Calendar calLlegada = Calendar.getInstance();
    calLlegada.setTime(reserva.getReservacionHoraLlegada());
    calLlegada.add(Calendar.HOUR, 2);

    Date hespacioInicio = calInicio.getTime();
    Date hespacioLlegada = calLlegada.getTime();

    SimpleDateFormat formatDate;/*from ww  w .  j av  a 2s .  co m*/
    SimpleDateFormat formatTime;
    formatDate = new SimpleDateFormat("yyyy-MM-dd");
    formatTime = new SimpleDateFormat("HH:mm:ss");

    String FechaInicio = formatDate.format(reserva.getReservacionFechaInicio());
    String FechaLlegada = formatDate.format(reserva.getReservacionFechaLlegada());
    String HoraInicio = formatTime.format(reserva.getReservacionHoraInicio());
    String HoraLlegada = formatTime.format(reserva.getReservacionHoraLlegada());
    String espacioinicio = formatTime.format(hespacioInicio);
    String espacioLlegada = formatTime.format(hespacioLlegada);

    vehiculosListView = vehDao.consultarVehiculosDisponibles(FechaInicio, FechaLlegada, HoraInicio, HoraLlegada,
            ciudadVeh, espacioinicio, espacioLlegada, mercadoSeleccionado, categoriaServicio);
    return vehiculosListView;
}

From source file:com.p2p.misc.DeviceUtility.java

public String dateNTime() {
    // date and time
    Calendar c = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("a");

    String amOrPm = df.format(c.getTime());

    Calendar ci = Calendar.getInstance();

    String CiDateTime = "" + ci.get(Calendar.DAY_OF_MONTH) + "/" + (ci.get(Calendar.MONTH) + 1) + "/"
            + ci.get(Calendar.YEAR) + " " + "  TIME-" + ci.get(Calendar.HOUR) + ":" + ci.get(Calendar.MINUTE)
            + " " + amOrPm;

    return CiDateTime;
}

From source file:net.yacy.grid.io.index.YaCyQuery.java

private QueryBuilder parse(String q, int timezoneOffset) {
    // detect usage of OR ORconnective usage. Because of the preparse step we will have only OR or only AND here.
    q = q.replaceAll(" AND ", " "); // AND is default
    boolean ORconnective = q.indexOf(" OR ") >= 0;
    q = q.replaceAll(" OR ", " "); // if we know that all terms are OR, we remove that and apply it later. Because we splitted into OR groups it is right to use OR here only

    // tokenize the query
    Set<String> qe = new LinkedHashSet<String>();
    Matcher m = tokenizerPattern.matcher(q);
    while (m.find())
        qe.add(m.group(1));//from ww  w. ja v  a2 s  .  c om

    // twitter search syntax:
    //   term1 term2 term3 - all three terms shall appear
    //   "term1 term2 term3" - exact match of all terms
    //   term1 OR term2 OR term3 - any of the three terms shall appear
    //   from:user - tweets posted from that user
    //   to:user - tweets posted to that user
    //   @user - tweets which mention that user
    //   near:"location" within:xmi - tweets that are near that location
    //   #hashtag - tweets containing the given hashtag
    //   since:2015-04-01 until:2015-04-03 - tweets within given time range
    // additional constraints:
    //   /image /audio /video /place - restrict to tweets which have attached images, audio, video or place
    ArrayList<String> text_positive_match = new ArrayList<>();
    ArrayList<String> text_negative_match = new ArrayList<>();
    ArrayList<String> text_positive_filter = new ArrayList<>();
    ArrayList<String> text_negative_filter = new ArrayList<>();
    Multimap<String, String> modifier = HashMultimap.create();
    Set<String> constraints_positive = new HashSet<>();
    Set<String> constraints_negative = new HashSet<>();
    for (String t : qe) {
        if (t.length() == 0)
            continue;
        if (t.startsWith("/")) {
            constraints_positive.add(t.substring(1));
            continue;
        } else if (t.startsWith("-/")) {
            constraints_negative.add(t.substring(2));
            continue;
        } else if (t.indexOf(':') > 0) {
            int p = t.indexOf(':');
            String name = t.substring(0, p).toLowerCase();
            String value = t.substring(p + 1);
            if (value.indexOf('|') > 0) {
                String[] values = value.split("\\|");
                for (String v : values) {
                    modifier.put(name, v);
                }
            } else {
                modifier.put(name, value);
            }
            continue;
        } else {
            // patch characters that will confuse elasticsearch or have a different meaning
            boolean negative = t.startsWith("-");
            if (negative)
                t = t.substring(1);
            if (t.length() == 0)
                continue;
            if ((t.charAt(0) == dq && t.charAt(t.length() - 1) == dq)
                    || (t.charAt(0) == sq && t.charAt(t.length() - 1) == sq)) {
                t = t.substring(1, t.length() - 1);
                if (negative) {
                    text_negative_filter.add(t);
                    this.negativeBag.add(t);
                } else {
                    text_positive_filter.add(t);
                    this.positiveBag.add(t);
                }
            } else if (t.indexOf('-') > 0) {
                // this must be handled like a quoted string without the minus
                t = t.replace('-', space);
                if (negative) {
                    text_negative_filter.add(t);
                    this.negativeBag.add(t);
                } else {
                    text_positive_filter.add(t);
                    this.positiveBag.add(t);
                }
            } else {
                if (negative) {
                    text_negative_match.add(t);
                    this.negativeBag.add(t);
                } else {
                    text_positive_match.add(t);
                    this.positiveBag.add(t);
                }
            }
            continue;
        }
    }

    // construct a ranking
    if (modifier.containsKey("boost")) {
        this.boosts.patchWithModifier(modifier.get("boost").iterator().next());
    }

    // compose query for text
    List<QueryBuilder> queries = new ArrayList<>();
    // fuzzy matching
    if (!text_positive_match.isEmpty())
        queries.add(simpleQueryBuilder(String.join(" ", text_positive_match), ORconnective, boosts));
    if (!text_negative_match.isEmpty())
        queries.add(QueryBuilders.boolQuery()
                .mustNot(simpleQueryBuilder(String.join(" ", text_negative_match), ORconnective, boosts)));
    // exact matching
    for (String text : text_positive_filter) {
        queries.add(exactMatchQueryBuilder(text, this.boosts));
    }
    for (String text : text_negative_filter) {
        queries.add(QueryBuilders.boolQuery().mustNot(exactMatchQueryBuilder(text, this.boosts)));
    }

    // apply modifiers
    Collection<String> values;
    modifier_handling: for (String[] modifierType : modifierTypes) {
        String modifier_name = modifierType[0];
        String index_name = modifierType[1];

        if ((values = modifier.get(modifier_name)).size() > 0) {
            if (modifier_name.equals("yacy")) {
                values.forEach(y -> this.yacyModifiers.add(y));
                continue modifier_handling;
            }
            if (modifier_name.equals("site") && values.size() == 1) {
                String host = values.iterator().next();
                if (host.startsWith("www."))
                    values.add(host.substring(4));
                else
                    values.add("www." + host);
            }
            queries.add(QueryBuilders.constantScoreQuery(QueryBuilders.termsQuery(index_name, values)));
            continue modifier_handling;
        }

        if ((values = modifier.get("-" + modifier_name)).size() > 0) {
            if (modifier_name.equals("site") && values.size() == 1) {
                String host = values.iterator().next();
                if (host.startsWith("www."))
                    values.add(host.substring(4));
                else
                    values.add("www." + host);
            }
            queries.add(QueryBuilders.boolQuery()
                    .mustNot(QueryBuilders.constantScoreQuery(QueryBuilders.termsQuery(index_name, values))));
            continue modifier_handling;
        }
    }
    if (modifier.containsKey("collection") && (this.collections == null || this.collections.length == 0)) {
        Collection<String> c = modifier.get("collection");
        this.collections = c.toArray(new String[c.size()]);
    }
    if (modifier.containsKey("daterange")) {
        String dr = modifier.get("daterange").iterator().next();
        if (dr.length() > 0) {
            String from_to[] = dr.endsWith("..") ? new String[] { dr.substring(0, dr.length() - 2), "" }
                    : dr.startsWith("..") ? new String[] { "", dr.substring(2) } : dr.split("\\.\\.");
            if (from_to.length == 2) {
                if (from_to[0] != null && from_to[0].length() > 0)
                    try {
                        modifier.put("since", DateParser.dayDateFormat
                                .format(DateParser.parse(from_to[0], timezoneOffset).getTime()));
                    } catch (ParseException e) {
                    }
                if (from_to[1] != null && from_to[1].length() > 0)
                    try {
                        modifier.put("until", DateParser.dayDateFormat
                                .format(DateParser.parse(from_to[1], timezoneOffset).getTime()));
                    } catch (ParseException e) {
                    }
            }
        }
    }
    if (modifier.containsKey("since"))
        try {
            Calendar since = DateParser.parse(modifier.get("since").iterator().next(), timezoneOffset);
            this.since = since.getTime();
            RangeQueryBuilder rangeQuery = QueryBuilders
                    .rangeQuery(WebMapping.last_modified.getMapping().name())
                    .from(DateParser.formatGSAFS(this.since));
            if (modifier.containsKey("until")) {
                Calendar until = DateParser.parse(modifier.get("until").iterator().next(), timezoneOffset);
                if (until.get(Calendar.HOUR) == 0 && until.get(Calendar.MINUTE) == 0) {
                    // until must be the day which is included in results.
                    // To get the result within the same day, we must add one day.
                    until.add(Calendar.DATE, 1);
                }
                this.until = until.getTime();
                rangeQuery.to(DateParser.formatGSAFS(this.until));
            } else {
                this.until = new Date(Long.MAX_VALUE);
            }
            queries.add(rangeQuery);
        } catch (ParseException e) {
        }
    else if (modifier.containsKey("until"))
        try {
            Calendar until = DateParser.parse(modifier.get("until").iterator().next(), timezoneOffset);
            if (until.get(Calendar.HOUR) == 0 && until.get(Calendar.MINUTE) == 0) {
                // until must be the day which is included in results.
                // To get the result within the same day, we must add one day.
                until.add(Calendar.DATE, 1);
            }
            this.until = until.getTime();
            RangeQueryBuilder rangeQuery = QueryBuilders
                    .rangeQuery(WebMapping.last_modified.getMapping().name())
                    .to(DateParser.formatGSAFS(this.until));
            queries.add(rangeQuery);
        } catch (ParseException e) {
        }

    // now combine queries with OR or AND operator

    // simple case where we have one query only
    if (queries.size() == 1) {
        return queries.iterator().next();
    }

    BoolQueryBuilder b = QueryBuilders.boolQuery();
    for (QueryBuilder filter : queries) {
        if (ORconnective)
            b.should(filter);
        else
            b.must(filter);
    }
    if (ORconnective)
        b.minimumShouldMatch(1);

    return b;
}

From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java

public static void importArticle(PortletDataContext portletDataContext, Element articleElement)
        throws Exception {

    String path = articleElement.attributeValue("path");

    if (!portletDataContext.isPathNotProcessed(path)) {
        return;/*from   w  ww  .  java  2 s. c  o m*/
    }

    JournalArticle article = (JournalArticle) portletDataContext.getZipEntryAsObject(path);

    prepareLanguagesForImport(article);

    long userId = portletDataContext.getUserId(article.getUserUuid());

    JournalCreationStrategy creationStrategy = JournalCreationStrategyFactory.getInstance();

    long authorId = creationStrategy.getAuthorUserId(portletDataContext, article);

    if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) {
        userId = authorId;
    }

    User user = UserLocalServiceUtil.getUser(userId);

    String articleId = article.getArticleId();
    boolean autoArticleId = false;

    Map<String, String> articleIds = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(JournalArticle.class + ".articleId");

    String newArticleId = articleIds.get(articleId);

    // ======= Start of change ============
    if (Validator.isNotNull(newArticleId)) {

        // A sibling of a different version was already assigned a new
        // article id

        articleId = newArticleId;
    }
    // =======end of change================

    String content = article.getContent();

    content = importDLFileEntries(portletDataContext, articleElement, content);

    Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId());

    content = StringUtil.replace(content, "@data_handler_group_friendly_url@", group.getFriendlyURL());

    content = importLinksToLayout(portletDataContext, content);

    article.setContent(content);

    String newContent = creationStrategy.getTransformedContent(portletDataContext, article);

    if (!StringUtils.equals(JournalCreationStrategy.ARTICLE_CONTENT_UNCHANGED, newContent)) {
        article.setContent(newContent);
    }

    Map<String, String> structureIds = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(JournalStructure.class);

    String parentStructureId = MapUtil.getString(structureIds, article.getStructureId(),
            article.getStructureId());

    Map<String, String> templateIds = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(JournalTemplate.class);

    String parentTemplateId = MapUtil.getString(templateIds, article.getTemplateId(), article.getTemplateId());

    Date displayDate = article.getDisplayDate();

    int displayDateMonth = 0;
    int displayDateDay = 0;
    int displayDateYear = 0;
    int displayDateHour = 0;
    int displayDateMinute = 0;

    if (displayDate != null) {
        Calendar displayCal = CalendarFactoryUtil.getCalendar(user.getTimeZone());

        displayCal.setTime(displayDate);

        displayDateMonth = displayCal.get(Calendar.MONTH);
        displayDateDay = displayCal.get(Calendar.DATE);
        displayDateYear = displayCal.get(Calendar.YEAR);
        displayDateHour = displayCal.get(Calendar.HOUR);
        displayDateMinute = displayCal.get(Calendar.MINUTE);

        if (displayCal.get(Calendar.AM_PM) == Calendar.PM) {
            displayDateHour += 12;
        }
    }

    Date expirationDate = article.getExpirationDate();

    int expirationDateMonth = 0;
    int expirationDateDay = 0;
    int expirationDateYear = 0;
    int expirationDateHour = 0;
    int expirationDateMinute = 0;
    boolean neverExpire = true;

    if (expirationDate != null) {
        Calendar expirationCal = CalendarFactoryUtil.getCalendar(user.getTimeZone());

        expirationCal.setTime(expirationDate);

        expirationDateMonth = expirationCal.get(Calendar.MONTH);
        expirationDateDay = expirationCal.get(Calendar.DATE);
        expirationDateYear = expirationCal.get(Calendar.YEAR);
        expirationDateHour = expirationCal.get(Calendar.HOUR);
        expirationDateMinute = expirationCal.get(Calendar.MINUTE);
        neverExpire = false;

        if (expirationCal.get(Calendar.AM_PM) == Calendar.PM) {
            expirationDateHour += 12;
        }
    }

    Date reviewDate = article.getReviewDate();

    int reviewDateMonth = 0;
    int reviewDateDay = 0;
    int reviewDateYear = 0;
    int reviewDateHour = 0;
    int reviewDateMinute = 0;
    boolean neverReview = true;

    if (reviewDate != null) {
        Calendar reviewCal = CalendarFactoryUtil.getCalendar(user.getTimeZone());

        reviewCal.setTime(reviewDate);

        reviewDateMonth = reviewCal.get(Calendar.MONTH);
        reviewDateDay = reviewCal.get(Calendar.DATE);
        reviewDateYear = reviewCal.get(Calendar.YEAR);
        reviewDateHour = reviewCal.get(Calendar.HOUR);
        reviewDateMinute = reviewCal.get(Calendar.MINUTE);
        neverReview = false;

        if (reviewCal.get(Calendar.AM_PM) == Calendar.PM) {
            reviewDateHour += 12;
        }
    }

    long structurePrimaryKey = 0;

    if (Validator.isNotNull(article.getStructureId())) {
        String structureUuid = articleElement.attributeValue("structure-uuid");

        JournalStructure existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid,
                portletDataContext.getScopeGroupId());

        if (existingStructure == null) {
            Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());

            long companyGroupId = companyGroup.getGroupId();

            existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid, companyGroupId);
        }

        if (existingStructure == null) {
            String newStructureId = structureIds.get(article.getStructureId());

            if (Validator.isNotNull(newStructureId)) {
                existingStructure = JournalStructureUtil.fetchByG_S(portletDataContext.getScopeGroupId(),
                        String.valueOf(newStructureId));
            }

            if (existingStructure == null) {
                if (_log.isWarnEnabled()) {
                    StringBundler sb = new StringBundler();

                    sb.append("Structure ");
                    sb.append(article.getStructureId());
                    sb.append(" is missing for article ");
                    sb.append(article.getArticleId());
                    sb.append(", skipping this article.");

                    _log.warn(sb.toString());
                }

                return;
            }
        }

        structurePrimaryKey = existingStructure.getPrimaryKey();

        parentStructureId = existingStructure.getStructureId();
    }

    if (Validator.isNotNull(article.getTemplateId())) {
        String templateUuid = articleElement.attributeValue("template-uuid");

        JournalTemplate existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid,
                portletDataContext.getScopeGroupId());

        if (existingTemplate == null) {
            Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());

            long companyGroupId = companyGroup.getGroupId();

            existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid, companyGroupId);
        }

        if (existingTemplate == null) {
            String newTemplateId = templateIds.get(article.getTemplateId());

            if (Validator.isNotNull(newTemplateId)) {
                existingTemplate = JournalTemplateUtil.fetchByG_T(portletDataContext.getScopeGroupId(),
                        newTemplateId);
            }

            if (existingTemplate == null) {
                if (_log.isWarnEnabled()) {
                    StringBundler sb = new StringBundler();

                    sb.append("Template ");
                    sb.append(article.getTemplateId());
                    sb.append(" is missing for article ");
                    sb.append(article.getArticleId());
                    sb.append(", skipping this article.");

                    _log.warn(sb.toString());
                }

                return;
            }
        }

        parentTemplateId = existingTemplate.getTemplateId();
    }

    File smallFile = null;

    String smallImagePath = articleElement.attributeValue("small-image-path");

    if (article.isSmallImage() && Validator.isNotNull(smallImagePath)) {
        byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath);

        smallFile = FileUtil.createTempFile(article.getSmallImageType());

        FileUtil.write(smallFile, bytes);
    }

    Map<String, byte[]> images = new HashMap<String, byte[]>();

    String imagePath = articleElement.attributeValue("image-path");

    if (portletDataContext.getBooleanParameter(_NAMESPACE, "images") && Validator.isNotNull(imagePath)) {

        List<String> imageFiles = portletDataContext.getZipFolderEntries(imagePath);

        for (String imageFile : imageFiles) {
            String fileName = imageFile;

            if (fileName.contains(StringPool.SLASH)) {
                fileName = fileName.substring(fileName.lastIndexOf(CharPool.SLASH) + 1);
            }

            if (fileName.endsWith(".xml")) {
                continue;
            }

            int pos = fileName.lastIndexOf(CharPool.PERIOD);

            if (pos != -1) {
                fileName = fileName.substring(0, pos);
            }

            images.put(fileName, portletDataContext.getZipEntryAsByteArray(imageFile));
        }
    }

    String articleURL = null;

    boolean addGroupPermissions = creationStrategy.addGroupPermissions(portletDataContext, article);
    boolean addGuestPermissions = creationStrategy.addGuestPermissions(portletDataContext, article);

    ServiceContext serviceContext = portletDataContext.createServiceContext(articleElement, article,
            _NAMESPACE);

    serviceContext.setAddGroupPermissions(addGroupPermissions);
    serviceContext.setAddGuestPermissions(addGuestPermissions);
    serviceContext.setAttribute("imported", Boolean.TRUE.toString());

    if (article.getStatus() != WorkflowConstants.STATUS_APPROVED) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    }

    JournalArticle importedArticle = null;

    String articleResourceUuid = articleElement.attributeValue("article-resource-uuid");

    if (portletDataContext.isDataStrategyMirror()) {
        JournalArticleResource articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid,
                portletDataContext.getScopeGroupId());

        if (articleResource == null) {
            Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());

            long companyGroupId = companyGroup.getGroupId();

            articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid, companyGroupId);
        }
        //Modification start
        if (articleResource == null) {
            articleResource = JournalArticleResourceUtil.fetchByG_A(portletDataContext.getScopeGroupId(),
                    articleId);
        }
        //Modification end
        serviceContext.setUuid(articleResourceUuid);

        JournalArticle existingArticle = null;

        if (articleResource != null) {
            try {
                existingArticle = JournalArticleLocalServiceUtil.getLatestArticle(
                        articleResource.getResourcePrimKey(), WorkflowConstants.STATUS_ANY, false);
            } catch (NoSuchArticleException nsae) {
            }
        }

        if (existingArticle == null) {
            existingArticle = JournalArticleUtil.fetchByG_A_V(portletDataContext.getScopeGroupId(),
                    newArticleId, article.getVersion());
        }

        if (existingArticle == null) {
            importedArticle = JournalArticleLocalServiceUtil.addArticle(userId,
                    portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey,
                    articleId, autoArticleId, article.getVersion(), article.getTitleMap(),
                    article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId,
                    parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay,
                    displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay,
                    expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth,
                    reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
                    article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile,
                    images, articleURL, serviceContext);
        } else {
            importedArticle = JournalArticleLocalServiceUtil.updateArticle(userId, existingArticle.getGroupId(),
                    existingArticle.getArticleId(), existingArticle.getVersion(), article.getTitleMap(),
                    article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId,
                    parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay,
                    displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay,
                    expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth,
                    reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
                    article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile,
                    images, articleURL, serviceContext);
        }
    } else {
        importedArticle = JournalArticleLocalServiceUtil.addArticle(userId,
                portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey, articleId,
                autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(),
                article.getContent(), article.getType(), parentStructureId, parentTemplateId,
                article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
                displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear,
                expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay,
                reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(),
                article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL,
                serviceContext);
    }

    if (smallFile != null) {
        smallFile.delete();
    }

    portletDataContext.importClassedModel(article, importedArticle, _NAMESPACE);

    if (Validator.isNull(newArticleId)) {
        articleIds.put(article.getArticleId(), importedArticle.getArticleId());
    }

    Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());

    if (importedArticle.getGroupId() == companyGroup.getGroupId()) {
        portletDataContext.addCompanyReference(JournalArticle.class, articleId);
    }

    if (!articleId.equals(importedArticle.getArticleId())) {
        if (_log.isWarnEnabled()) {
            _log.warn("An article with the ID " + articleId + " already " + "exists. The new generated ID is "
                    + importedArticle.getArticleId());
        }
    }
}

From source file:com.useeasy.auction.action.GuestApplicationAction.java

public String doApply() {
    logger.info(//from w  w w  .j  av  a2  s  .co m
            "" + ((SessionContainer) ActionContext.getContext().getSession().get(Constants.SESEION_LISTENER))
                    .getAuctionAccount().getId());
    String mothed = ServletActionContext.getRequest().getMethod();
    if (!"post".equalsIgnoreCase(mothed)) {
        return "sessionDestory";
    }

    //String submitFlag = ServletActionContext.getRequest().getParameter("submitFlag");
    String auctionFlag = ServletActionContext.getRequest().getParameter("auctionFlag");
    if (auctionFlag == null) {
        return "sessionDestory";
    }

    SessionContainer sessionContainer = (SessionContainer) ActionContext.getContext().getSession()
            .get(Constants.SESEION_LISTENER);
    String account_id = "" + sessionContainer.getAuctionAccount().getId();

    AuctionInfo auctionInfo = iAuctionInfo.getAuctionInfo(auctionFlag);
    if (auctionInfo == null || ("1").equals(auctionInfo.getDeleteFlag())
            || ("0").equals(auctionInfo.getPublishFlag())) {
        return "sessionDestory";
    }

    if (("2").equals(auctionInfo.getAuctionStatus())) {
        return "applyed";
    }

    ApplicationInfo applicationInfo = iApplication.getApplicationByAccountAndAuctionId(account_id, auctionFlag);
    if (applicationInfo != null) {
        return "applyed";
    } else {
        String applyContent = ServletActionContext.getRequest().getParameter("applyContent");
        applicationInfo = new ApplicationInfo();

        applicationInfo.setId(null);
        applicationInfo.setCreateTime(new Date());
        applicationInfo.setUpdateTime(new Date());
        applicationInfo.setDeleteFlag("0");
        applicationInfo.setAccountId(account_id);
        applicationInfo.setAuctionId(auctionFlag);
        applicationInfo.setApplyContent(applyContent);
        applicationInfo.setCompanyId(auctionInfo.getAuctionCompanyId());

        if (!iQulification.checkQulification(account_id)) { //?
            applicationInfo.setApplyStatus("0");
            iApplication.saveApplication(applicationInfo);
            return "applyed";
        } else {
            applicationInfo.setApplyStatus("1");
            iApplication.saveApplication(applicationInfo);
        }

        String marginFlag = ServletActionContext.getRequest().getParameter("margin_radio");
        if ("2".equals(marginFlag)) { //alive_pay
            return "applyed";
        } else {
            String marginVal = ServletActionContext.getRequest().getParameter("margin_val");
            if (marginVal == null || "-1".equals(marginVal) || ("1").equals(auctionInfo.getAuctionStatus())) {
                return "applyed";
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date());
                int year = cal.get(Calendar.YEAR);
                int month = cal.get(Calendar.MONTH) + 1;
                int day = cal.get(Calendar.DATE);
                int hours = cal.get(Calendar.HOUR);
                int minutes = cal.get(Calendar.MINUTE);
                int seconds = cal.get(Calendar.SECOND);

                String monthVal = ((month < 10) ? "0" : "") + month;
                String dayVal = ((day < 10) ? "0" : "") + day;
                String hoursVal = ((hours < 10) ? "0" : "") + hours;
                String minutesVal = ((minutes < 10) ? "0" : "") + minutes;
                String secondsVal = ((seconds < 10) ? "0" : "") + seconds;

                String orderId = year + monthVal + dayVal + hoursVal + minutesVal + secondsVal;
                String orderDate = year + monthVal + dayVal;
                String orderTime = hoursVal + minutesVal + secondsVal;
                String companyLiscence = iCompanyInfo.getCompanyInfo(auctionInfo.getAuctionCompanyId())
                        .getCompanyLicense();

                PayBean payBean = new PayBean();
                payBean.setMerID(companyLiscence);
                payBean.setOrderid(orderId);
                payBean.setOrderDate(orderDate);
                payBean.setOrderTime(orderTime);
                //payBean.setAmount("1");
                payBean.setAmount(marginVal);
                payBean.setOrderContent("");
                payBean.setOrderMono("");
                payBean.setNotifyType("0");
                payBean.setMerURL("");
                payBean.setGoodsURL(
                        Constants.EBANK_RETURN_URL + ServletActionContext.getRequest().getContextPath()
                                + "/guestApplication_showApply?applyFlag=" + applicationInfo.getId());
                logger.info("urlrulrulrur_______________________" + payBean.getGoodsURL());
                payBean.setJumpSeconds("");
                payBean.setPayBatchNo("");
                payBean.setProxyMerName("");
                payBean.setProxyMerType("");
                payBean.setProxyMerCredentials("");

                String formUrl = PayMent.merchant(payBean);
                logger.info("url:____" + formUrl);

                PayRecordInfo payRecordInfo = new PayRecordInfo();
                payRecordInfo.setId(null);
                payRecordInfo.setCreateTime(new Date());
                payRecordInfo.setUpdateTime(new Date());
                payRecordInfo.setDeleteFlag("0");
                payRecordInfo.setAccountId(account_id);
                payRecordInfo.setAuctionId("" + auctionInfo.getId());
                payRecordInfo.setCompanyId(auctionInfo.getAuctionCompanyId());
                payRecordInfo.setOrderId(orderId);
                payRecordInfo.setOrderTime(new Date());
                payRecordInfo.setPayMoney(marginVal);
                payRecordInfo.setMerchantId(companyLiscence);
                payRecordInfo.setPayStatus("0");
                payRecordInfo.setPayType("2");
                iPayRecordInfo.savePayRecordInfo(payRecordInfo);

                logger.info("??________" + orderId);

                ServletActionContext.getRequest().setAttribute("formUrl", formUrl);
                ServletActionContext.getRequest().setAttribute("payBean", payBean);
                return "bankUrl";// 
            }
        }
    }

}

From source file:fedora.server.security.servletfilters.CacheElement.java

private static final int calcCalendarUnit(String unit) {
    String m = "- calcCalendarUnit() ";
    int rc = Calendar.SECOND;
    if (!unit.endsWith("s")) {
        unit += "s";
    }//from  www.  ja  va  2 s . c  o  m
    if ("milliseconds".equalsIgnoreCase(unit)) {
        rc = Calendar.MILLISECOND;
    } else if ("seconds".equalsIgnoreCase(unit)) {
        rc = Calendar.SECOND;
    } else if ("minutes".equalsIgnoreCase(unit)) {
        rc = Calendar.MINUTE;
    } else if ("hours".equalsIgnoreCase(unit)) {
        rc = Calendar.HOUR;
    } else {
        String msg = "illegal Calendar unit: " + unit;
        LOG.error(m + "(" + msg + ")");
        throw new IllegalArgumentException(msg);
    }
    return rc;
}

From source file:com.eryansky.common.utils.DateUtil.java

/**
 * ?Calender?Calender?  20090802080808 ?
 * //from w ww  .j a  va  2 s  .c  o m
 */
public static long getLongTime() {
    try {
        long longCalendar = 0;

        // ?
        Calendar cldCurrent = Calendar.getInstance();

        // 
        String strYear = String.valueOf(cldCurrent.get(Calendar.YEAR));
        String strMonth = String.valueOf(cldCurrent.get(Calendar.MONTH) + 1);
        String strDate = String.valueOf(cldCurrent.get(Calendar.DATE));
        String strHour = String.valueOf(cldCurrent.get(Calendar.HOUR));
        String strAM_PM = String.valueOf(cldCurrent.get(Calendar.AM_PM));
        String strMinute = String.valueOf(cldCurrent.get(Calendar.MINUTE));
        String strSecond = String.valueOf(cldCurrent.get(Calendar.SECOND));

        // ?24?
        // strAM_PM=="1",??strHour?12
        if (strAM_PM.equals("1")) {
            strHour = String.valueOf(Long.parseLong(strHour) + 12);
        }

        // ??
        if (strMonth.length() < 2) {
            strMonth = "0" + strMonth;
        }
        if (strDate.length() < 2) {
            strDate = "0" + strDate;
        }
        if (strHour.length() < 2) {
            strHour = "0" + strHour;
        }
        if (strMinute.length() < 2) {
            strMinute = "0" + strMinute;
        }
        if (strSecond.length() < 2) {
            strSecond = "0" + strSecond;
        }
        // ?
        longCalendar = Long.parseLong(strYear + strMonth + strDate + strHour + strMinute + strSecond);

        // ?
        return longCalendar;
    } catch (Exception Exp) {
        return 0;
    }
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getIntervalo() {
    JPanel intervalo = new JPanel(new GridBagLayout());
    intervalo.setOpaque(false);/* ww  w  .j a  v a2  s .  co m*/
    intervalo.setBorder(new TitledBorder("Intervalo Temporal de Consulta"));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    intervalo.add(new JLabel("Fecha/Hora Inicial"), gbc);
    gbc.gridx++;
    calendarini = new JCalendarCombo();
    calendarini.addActionListener(actionListener);
    calendarini.addDateListener(dateListener);
    intervalo.add(calendarini, gbc);
    gbc.gridx++;
    final Calendar instance = Calendar.getInstance();
    instance.set(Calendar.HOUR, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    horaini = initializeSpinner(instance);
    intervalo.add(horaini, gbc);

    gbc.gridx = 0;
    gbc.gridy++;

    intervalo.add(new JLabel("Fecha/Hora Final"), gbc);
    gbc.gridx++;
    calendarfin = new JCalendarCombo();
    calendarfin.addActionListener(actionListener);
    calendarfin.addDateListener(dateListener);
    intervalo.add(calendarfin, gbc);
    gbc.gridx++;
    horafin = initializeSpinner(instance);
    intervalo.add(horafin, gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.EAST;
    soloUltimas = new JCheckBox();
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRecursos();
        }
    });
    soloUltimas.setOpaque(false);
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean enabled = !soloUltimas.isSelected();
            calendarini.setEnabled(enabled);
            calendarfin.setEnabled(enabled);
            horaini.setEnabled(enabled);
            horafin.setEnabled(enabled);
        }
    });
    intervalo.add(soloUltimas, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.WEST;
    intervalo.add(new JLabel("Consultar Slo Las ltimas Posiciones"), gbc);

    return intervalo;
}

From source file:com.ecofactor.qa.automation.consumerapi.DRAPI_Test.java

@Test(groups = {
        Groups.SANITY1 }, dataProvider = "drEventForAddingAnEvent", dataProviderClass = DRAPIDataProvider.class, priority = 11)
public void addingEvent(final String Url, final String programId, final String eventId, final String targetType,
        final String jSon, final String event) {

    long timeStamp = System.currentTimeMillis();

    final int eventValue = Integer.parseInt(event);
    int count = 0;
    String createUrl = Url;//from w w w  .jav  a 2s . c o m

    createUrl = createUrl.replaceFirst("<program_id>", programId)
            .replaceFirst("<event_id>", eventId + timeStamp).replaceFirst("<target_type>", targetType)
            .replaceFirst("<target_all>", "true");

    String json = jSon;
    json = json
            .replaceFirst("<start_time>",
                    Long.toString(DateUtil.subtractFromUTCMilliSeconds(Calendar.MINUTE, 5)))
            .replaceFirst("<end_time>", Long.toString(DateUtil.addToUTCMilliSeconds(Calendar.HOUR, 2)));

    setLogString("URL Values of the API \n" + createUrl + "\n" + json, true);

    final HttpResponse response = HTTPSClient.postResponse(createUrl, json,
            HTTPSClient.getPKCSKeyHttpClient("ecofactorcorp.p12", "ecofactor"));
    Assert.assertTrue(response.getStatusLine().getStatusCode() == 200,
            "Error status: " + response.getStatusLine());

    if (count > 0) {

    }
    final String result = HTTPSClient.getResultString(response.getEntity());
    setLogString("response :'" + result + " " + "Exceeds the maximum Events " + "'", true);

}

From source file:fr.inria.ucn.Helpers.java

/**
 * @param c//from   ww  w.ja v  a  2 s . c  o  m
 * @return <code>True</code> if user has enabled the night-time mode and current time is
 * within night, else <code>False</code>.
 */
public static boolean isNightTime(Context c) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    if (!prefs.getBoolean(Constants.PREF_STOP_NIGHT, false))
        return false;

    int nstart = prefs.getInt(Constants.PREF_NIGHT_START, 23 * 3600);
    int nstop = prefs.getInt(Constants.PREF_NIGHT_STOP, 6 * 3600);

    Calendar nightstart = Calendar.getInstance();
    nightstart.roll(Calendar.HOUR_OF_DAY, -1 * nightstart.get(Calendar.HOUR_OF_DAY));
    nightstart.roll(Calendar.MINUTE, -1 * nightstart.get(Calendar.MINUTE));
    nightstart.roll(Calendar.SECOND, -1 * nightstart.get(Calendar.SECOND));
    nightstart.roll(Calendar.MILLISECOND, -1 * nightstart.get(Calendar.MILLISECOND));
    nightstart.add(Calendar.SECOND, nstart);

    Calendar nightstop = Calendar.getInstance();
    nightstop.roll(Calendar.HOUR_OF_DAY, -1 * nightstop.get(Calendar.HOUR_OF_DAY));
    nightstop.roll(Calendar.MINUTE, -1 * nightstop.get(Calendar.MINUTE));
    nightstop.roll(Calendar.SECOND, -1 * nightstop.get(Calendar.SECOND));
    nightstop.roll(Calendar.MILLISECOND, -1 * nightstop.get(Calendar.MILLISECOND));
    nightstop.add(Calendar.SECOND, nstop);
    if (nightstop.before(nightstart))
        nightstop.add(Calendar.HOUR, 24);

    Log.d(Constants.LOGTAG, "nightstart " + nstart + " -> " + nightstart.toString());
    Log.d(Constants.LOGTAG, "nightstop " + nstop + " -> " + nightstop.toString());

    Calendar now = Calendar.getInstance();
    return (now.after(nightstart) && now.before(nightstop));
}