Example usage for org.joda.time DateTime getDayOfMonth

List of usage examples for org.joda.time DateTime getDayOfMonth

Introduction

In this page you can find the example usage for org.joda.time DateTime getDayOfMonth.

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:manageBeans.AddAuctionMB.java

/**
 * Creates an auction with a product/*w  ww  .  j  a  v  a2  s  .  co m*/
 * @param product
 *          product to add to an auction
 * @return auction
 *          the new created auction
 */
private Auction createAuction(Product product) {
    DateTime currentTime = new DateTime();
    DateTime temp = new DateTime(endDate);
    DateTime end = new DateTime(temp.getYear(), temp.getMonthOfYear(), temp.getDayOfMonth(), endTime.getHours(),
            endTime.getMinutes());

    // Calculate duration from start to end date
    Duration duration = new Duration(currentTime, end);
    long durationSeconds = duration.getStandardSeconds();

    Auction auction = new Auction();
    auction.setDuration(durationSeconds);
    auction.setInitPrice(price);
    // All auctions are published. TODO remove field from db
    auction.setPublished(true);
    Calendar calendar = Calendar.getInstance();
    auction.setStartTime(calendar);
    auction.setProduct(product);
    auction.setUser(userFacade.getAuctionUser());
    return auction;
}

From source file:mobi.daytoday.DayToDay.DatePickerDialogFragment.java

License:Apache License

/**
 * Create and return the date picker dialog
 *//*from  w w  w.  j a v  a2  s  .c om*/
public Dialog onCreateDialog(Bundle arg) {
    String current = getArguments().getString("curDate");
    DateTime dt;

    if ("".equals(current)) {
        dt = new DateTime();

        Log.v(TAG, "year: " + dt.getYear() + " month: " + dt.getMonthOfYear() + " day: " + dt.getDayOfMonth());

    } else {
        try {
            dt = DateWrap.parseDate(current);
        } catch (Exception e) {
            // just ignore it and use now
            dt = new DateTime();
        }
    }

    return new DatePickerDialog(getActivity(), (OnDateSetListener) frag, dt.getYear(), dt.getMonthOfYear() - 1,
            dt.getDayOfMonth());
}

From source file:model.SqlInterface.java

/**
 * Used to generate the current tally of time spent today and this week.
 * //from  ww w . j a v a  2  s  .c  o  m
 * @param daySubTotal The current subtotal for today and this week.
 * 
 * @return Time object containing the total time for today and this week.
 */
public DateTime getDayTimeTotal(DateTime daySubTotal) {
    String day = "";
    String week = "";
    DateTime date = new DateTime();
    String dateString = "" + date.getYear() + date.getMonthOfYear() + date.getDayOfMonth();
    ResultSet rs;

    try {
        rs = statementHandler.executeQuery("select * from timelord where date = '" + dateString + "';");

        while (rs.next()) {
            day = rs.getString("dayTally");
            week = rs.getString("weekTally");
            System.out.println("SQL: " + day + " " + week);
            System.out.println("dayTally = " + rs.getString("dayTally"));
            System.out.println("weekTally = " + rs.getString("weekTally"));
            System.out.println("-----------------------------------------");
        }

        rs.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    DateTime time = new DateTime(0, 1, 1, 0, 0, 0, 0);
    try {
        time.plusHours(1);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return time;
}

From source file:models.MailTransaction.java

License:Apache License

/**
 * @return the Timestamp as String in the Format "dd.MM.yyyy hh:mm"
 *//*from ww w  .j av  a2  s.  c  om*/
public String getTsAsString() {
    DateTime dt = new DateTime(this.ts);
    String day = "";
    String mon = "";
    String hou = "";
    String min = "";

    // add a leading "0" if the value is under ten
    if (dt.getDayOfMonth() < 10) {
        day += "0";
    }
    day += String.valueOf(dt.getDayOfMonth());

    if (dt.getMonthOfYear() < 10) {
        mon += "0";
    }
    mon += String.valueOf(dt.getMonthOfYear());

    if (dt.getHourOfDay() < 10) {
        hou += "0";
    }
    hou += String.valueOf(dt.getHourOfDay());

    if (dt.getMinuteOfHour() < 10) {
        min += "0";
    }
    min += String.valueOf(dt.getMinuteOfHour());

    return day + "." + mon + "." + dt.getYear() + " " + hou + ":" + min;
}

From source file:models.MBox.java

License:Apache License

/**
 * @return the timestamp as string in the format "yyyy-MM-dd hh:mm" <br/>
 *         if its 0, then also 0 is returned
 *//*from   www .java 2  s  .  c o m*/
@JsonIgnore
public String getTSAsStringWithNull() {
    if (this.ts_Active == 0) {
        return "0";
    } else if (this.ts_Active == -1) {
        return "-1";
    } else {
        DateTime dt = new DateTime(this.ts_Active);
        StringBuilder timeString = new StringBuilder();
        // add a leading "0" if the value is under ten
        timeString.append(dt.getYear()).append("-");
        timeString.append(HelperUtils.addZero(dt.getMonthOfYear()));
        timeString.append("-");
        timeString.append(HelperUtils.addZero(dt.getDayOfMonth()));
        timeString.append(" ");
        timeString.append(HelperUtils.addZero(dt.getHourOfDay()));
        timeString.append(":");
        timeString.append(HelperUtils.addZero(dt.getMinuteOfHour()));
        return timeString.toString();
    }

}

From source file:module.mission.domain.Mission.java

License:Open Source License

private boolean isHoliday(final DateTime dateTime) {
    // TODO Possibly refactor this and place data in the repository...
    //      also this does not yet account for mobile holidays and local
    //      holidays depending on the persons working place.
    final int year = dateTime.getYear();
    final int monthOfYear = dateTime.getMonthOfYear();
    final int dayOfMonth = dateTime.getDayOfMonth();
    return (monthOfYear == 1 && dayOfMonth == 1) || (monthOfYear == 4 && dayOfMonth == 25)
            || (monthOfYear == 5 && dayOfMonth == 1) || (monthOfYear == 6 && dayOfMonth == 10)
            || (monthOfYear == 8 && dayOfMonth == 15) || (monthOfYear == 10 && dayOfMonth == 5)
            || (monthOfYear == 11 && dayOfMonth == 1) || (monthOfYear == 12 && dayOfMonth == 1)
            || (monthOfYear == 12 && dayOfMonth == 8) || (monthOfYear == 12 && dayOfMonth == 25)
            || (year == 2011 && monthOfYear == 4 && dayOfMonth == 22)
            || (year == 2011 && monthOfYear == 6 && dayOfMonth == 13)
            || (year == 2011 && monthOfYear == 6 && dayOfMonth == 23);
}

From source file:module.signed_workflow.domain.data.ActivitySignatureDataBean.java

License:Open Source License

/**
 * /*from   w  ww .ja v a 2  s.  c o  m*/
 * @return the SignatureId, this id should be unique and will identify the
 *         signed document
 */
@Override
public String generateSignatureId() {
    DateTime currentDateTime = new DateTime();
    String signatureId = getWorkflowProcess().getProcessNumber() + "-" + activity.getSimpleName() + "-"
            + currentDateTime.getYear() + "-" + currentDateTime.getMonthOfYear() + "-"
            + currentDateTime.getDayOfMonth() + "_" + currentDateTime.getMillis() + "_"
            + randomNrForSigIdGeneration.nextInt(100000);
    signatureId = StringUtils.replaceChars(signatureId, ' ', '_');
    return signatureId;

}

From source file:module.workingCapital.domain.EmailDigesterUtil.java

License:Open Source License

public static void executeTask() {
    final DateTime now = new DateTime();

    I18N.setLocale(new Locale(CoreConfiguration.getConfiguration().defaultLocale()));
    for (Person person : getPeopleToProcess()) {

        final User user = person.getUser();
        if (user.getPerson() != null && user.getExpenditurePerson() != null) {
            Authenticate.mock(user, "System Automation");

            try {
                final LocalizedString applicationTitle = Bennu.getInstance().getConfiguration()
                        .getApplicationSubTitle();
                final String applicationUrl = CoreConfiguration.getConfiguration().applicationUrl();
                final WorkingCapitalYear workingCapitalYear = WorkingCapitalYear.getCurrentYear();
                final LocalDate today = new LocalDate();
                final WorkingCapitalYear previousYear = today.getMonthOfYear() == Month.JANUARY
                        ? WorkingCapitalYear.findOrCreate(today.getYear() - 1)
                        : null;//from  www .  ja v a2 s  . co  m

                Map<String, List<WorkingCapitalProcessBean>> processesTypeMap = new LinkedHashMap<>();
                if (previousYear == null) {
                    processesTypeMap.put(TAKEN, getMissionProcessBeans(workingCapitalYear.getTaken()));
                    processesTypeMap.put(PENDING_APPROVAL,
                            getMissionProcessBeans(workingCapitalYear.getPendingAproval()));
                    processesTypeMap.put(PENDING_VERIFICATION,
                            getMissionProcessBeans(workingCapitalYear.getPendingVerification()));
                    processesTypeMap.put(PENDING_PROCESSING,
                            getMissionProcessBeans(workingCapitalYear.getPendingProcessing()));
                    processesTypeMap.put(PENDING_AUTHORIZATION,
                            getMissionProcessBeans(workingCapitalYear.getPendingAuthorization()));
                    processesTypeMap.put(PENDING_PAYMENT,
                            getMissionProcessBeans(workingCapitalYear.getPendingPayment()));
                } else {
                    processesTypeMap.put(TAKEN,
                            getMissionProcessBeans(previousYear.getTaken(workingCapitalYear.getTaken())));
                    processesTypeMap.put(PENDING_APPROVAL, getMissionProcessBeans(
                            previousYear.getPendingAproval(workingCapitalYear.getPendingAproval())));
                    processesTypeMap.put(PENDING_VERIFICATION, getMissionProcessBeans(
                            previousYear.getPendingVerification(workingCapitalYear.getPendingVerification())));
                    processesTypeMap.put(PENDING_PROCESSING, getMissionProcessBeans(
                            previousYear.getPendingProcessing(workingCapitalYear.getPendingProcessing())));
                    processesTypeMap.put(PENDING_AUTHORIZATION, getMissionProcessBeans(previousYear
                            .getPendingAuthorization(workingCapitalYear.getPendingAuthorization())));
                    processesTypeMap.put(PENDING_PAYMENT, getMissionProcessBeans(
                            previousYear.getPendingPayment(workingCapitalYear.getPendingPayment())));
                }

                final int totalPending = processesTypeMap.values().stream().map(Collection::size).reduce(0,
                        Integer::sum);

                if (totalPending > 0) {
                    Message.fromSystem().to(Group.users(user)).template("expenditures.capital.pending")
                            .parameter("applicationTitle", applicationTitle)
                            .parameter("applicationUrl", applicationUrl)
                            .parameter("processesByType", processesTypeMap)
                            .parameter("processesTotal", totalPending).and().send();
                }

                for (final WorkingCapital workingCapital : user.getPerson()
                        .getMovementResponsibleWorkingCapitalsSet()) {
                    final Integer year = workingCapital.getWorkingCapitalYear().getYear();
                    if (year.intValue() < now.getYear()
                            || (year.intValue() == now.getYear() && now.getMonthOfYear() == 12)
                                    && now.getDayOfMonth() > 15) {
                        final PresentableProcessState state = workingCapital
                                .getPresentableAcquisitionProcessState();
                        if (state == WorkingCapitalProcessState.WORKING_CAPITAL_AVAILABLE) {
                            Message.fromSystem().to(Group.users(user))
                                    .template("expenditures.capital.pending.termination")
                                    .parameter("applicationTitle", applicationTitle)
                                    .parameter("applicationUrl", applicationUrl)
                                    .parameter("unit", workingCapital.getUnit().getPresentationName())
                                    .parameter("year", workingCapital.getWorkingCapitalYear().getYear()).and()
                                    .send();
                        }
                    }
                }
            } finally {
                Authenticate.unmock();
            }
        }
    }
}

From source file:nbm.center.catalog.CatalogXmlFactory.java

License:Apache License

private String makeCatalogTimestampFrom(DateTime today) {
    String catalogTimestamp = "";
    catalogTimestamp += "00" + "/";
    catalogTimestamp += today.getMinuteOfHour() + "/";
    catalogTimestamp += today.getHourOfDay() + "/";
    catalogTimestamp += today.getDayOfMonth() + "/";
    catalogTimestamp += today.getMonthOfYear() + "/";
    catalogTimestamp += today.getYear();
    return catalogTimestamp;
}

From source file:nc.noumea.mairie.organigramme.core.utility.DateUtil.java

License:Open Source License

/**
 * Retoure une reprsentation de la date// w w  w  . java  2s .  com
 * @param date date concerne
 * @return exemple : "7 janvier 2014", "" si la date en entre est null
 */
public static String formatDateAvecMoisEnTexte(Date date) {
    if (date == null) {
        return "";
    }
    DateTime dateTime = new DateTime(date);
    return dateTime.getDayOfMonth() + " " + libelleMois(dateTime.getMonthOfYear()) + " " + dateTime.getYear();
}