Example usage for org.joda.time LocalDateTime LocalDateTime

List of usage examples for org.joda.time LocalDateTime LocalDateTime

Introduction

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

Prototype

public LocalDateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:com.gs.fw.common.mithra.util.Time.java

License:Apache License

public static Time withSqlTime(java.sql.Time sqlTime) {
    if (sqlTime == null)
        return null;

    LocalDateTime localDateTime = new LocalDateTime(sqlTime.getTime());
    return Time.withMillis(localDateTime.getHourOfDay(), localDateTime.getMinuteOfHour(),
            localDateTime.getSecondOfMinute(), localDateTime.getMillisOfSecond());
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

License:Apache License

public LocalDateTime getRecurrenceStartDateTime() {
    return (LocalDateTime) ObjectUtils.defaultIfNull(new LocalDateTime(this.recurrenceStartDate), null);
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

License:Apache License

public LocalDateTime getNextTriggerDate() {
    return (LocalDateTime) ObjectUtils.defaultIfNull(new LocalDateTime(this.nextTriggerDate), null);

}

From source file:com.gst.infrastructure.dataqueries.service.GenericDataServiceImpl.java

License:Apache License

@Override
public String generateJsonFromGenericResultsetData(final GenericResultsetData grs) {

    final StringBuffer writer = new StringBuffer();

    writer.append("[");

    final List<ResultsetColumnHeaderData> columnHeaders = grs.getColumnHeaders();

    final List<ResultsetRowData> data = grs.getData();
    List<String> row;
    Integer rSize;//  w  ww . j  av a 2s.c o m
    final String doubleQuote = "\"";
    final String slashDoubleQuote = "\\\"";
    String currColType;
    String currVal;

    for (int i = 0; i < data.size(); i++) {
        writer.append("\n{");

        row = data.get(i).getRow();
        rSize = row.size();
        for (int j = 0; j < rSize; j++) {

            writer.append(doubleQuote + columnHeaders.get(j).getColumnName() + doubleQuote + ": ");
            currColType = columnHeaders.get(j).getColumnDisplayType();
            final String colType = columnHeaders.get(j).getColumnType();
            if (currColType == null && colType.equalsIgnoreCase("INT")) {
                currColType = "INTEGER";
            }
            if (currColType == null && colType.equalsIgnoreCase("VARCHAR")) {
                currColType = "VARCHAR";
            }
            if (currColType == null && colType.equalsIgnoreCase("DATE")) {
                currColType = "DATE";
            }
            currVal = row.get(j);
            if (currVal != null && currColType != null) {
                if (currColType.equals("DECIMAL") || currColType.equals("INTEGER")) {
                    writer.append(currVal);
                } else {
                    if (currColType.equals("DATE")) {
                        final LocalDate localDate = new LocalDate(currVal);
                        writer.append("[" + localDate.getYear() + ", " + localDate.getMonthOfYear() + ", "
                                + localDate.getDayOfMonth() + "]");
                    } else if (currColType.equals("DATETIME")) {
                        final LocalDateTime localDateTime = new LocalDateTime(currVal);
                        writer.append("[" + localDateTime.getYear() + ", " + localDateTime.getMonthOfYear()
                                + ", " + localDateTime.getDayOfMonth() + " " + localDateTime.getHourOfDay()
                                + ", " + localDateTime.getMinuteOfHour() + ", "
                                + localDateTime.getSecondOfMinute() + ", " + localDateTime.getMillisOfSecond()
                                + "]");
                    } else {
                        writer.append(
                                doubleQuote + replace(currVal, doubleQuote, slashDoubleQuote) + doubleQuote);
                    }
                }
            } else {
                writer.append("null");
            }
            if (j < (rSize - 1)) {
                writer.append(",\n");
            }
        }

        if (i < (data.size() - 1)) {
            writer.append("},");
        } else {
            writer.append("}");
        }
    }

    writer.append("\n]");
    return writer.toString();

}

From source file:com.gst.infrastructure.reportmailingjob.domain.ReportMailingJob.java

License:Apache License

/** 
 * Update the ReportMailingJob entity //  w  w  w  .  j  a va2  s  .c o m
 * 
 * @param jsonCommand JsonCommand object
 * @return map of string to object
 **/
public Map<String, Object> update(final JsonCommand jsonCommand) {
    final Map<String, Object> actualChanges = new LinkedHashMap<>();

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.NAME_PARAM_NAME, this.name)) {
        final String name = jsonCommand.stringValueOfParameterNamed(ReportMailingJobConstants.NAME_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.NAME_PARAM_NAME, name);

        this.name = name;
    }

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME,
            this.description)) {
        final String description = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME, description);

        this.description = description;
    }

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.RECURRENCE_PARAM_NAME,
            this.recurrence)) {
        final String recurrence = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.RECURRENCE_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.RECURRENCE_PARAM_NAME, recurrence);

        this.recurrence = recurrence;
    }

    if (jsonCommand.isChangeInBooleanParameterNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME,
            this.isActive)) {
        final boolean isActive = jsonCommand
                .booleanPrimitiveValueOfParameterNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME, isActive);

        this.isActive = isActive;
    }

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME,
            this.emailRecipients)) {
        final String emailRecipients = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME, emailRecipients);

        this.emailRecipients = emailRecipients;
    }

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME,
            this.emailSubject)) {
        final String emailSubject = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME, emailSubject);

        this.emailSubject = emailSubject;
    }

    if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME,
            this.emailMessage)) {
        final String emailMessage = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME, emailMessage);

        this.emailMessage = emailMessage;
    }

    if (jsonCommand.isChangeInStringParameterNamed(
            ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME, this.stretchyReportParamMap)) {
        final String stretchyReportParamMap = jsonCommand
                .stringValueOfParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME,
                stretchyReportParamMap);

        this.stretchyReportParamMap = stretchyReportParamMap;
    }

    final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat
            .newInstance(this.emailAttachmentFileFormat);

    if (jsonCommand.isChangeInIntegerParameterNamed(
            ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME,
            emailAttachmentFileFormat.getId())) {
        final Integer emailAttachmentFileFormatId = jsonCommand.integerValueOfParameterNamed(
                ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME,
                emailAttachmentFileFormatId);

        final ReportMailingJobEmailAttachmentFileFormat newEmailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat
                .newInstance(emailAttachmentFileFormatId);
        this.emailAttachmentFileFormat = newEmailAttachmentFileFormat.getValue();
    }

    final String newStartDateTimeString = jsonCommand
            .stringValueOfParameterNamed(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME);

    if (!StringUtils.isEmpty(newStartDateTimeString)) {
        final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(jsonCommand.dateFormat())
                .withLocale(jsonCommand.extractLocale());
        final LocalDateTime newStartDateTime = LocalDateTime.parse(newStartDateTimeString, dateTimeFormatter);
        final LocalDateTime oldStartDateTime = (this.startDateTime != null)
                ? new LocalDateTime(this.startDateTime)
                : null;

        if ((oldStartDateTime != null) && !newStartDateTime.equals(oldStartDateTime)) {
            actualChanges.put(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME, newStartDateTimeString);

            this.startDateTime = newStartDateTime.toDate();
        }
    }

    Long currentStretchyReportId = null;

    if (this.stretchyReport != null) {
        currentStretchyReportId = this.stretchyReport.getId();
    }

    if (jsonCommand.isChangeInLongParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME,
            currentStretchyReportId)) {
        final Long updatedStretchyReportId = jsonCommand
                .longValueOfParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME);
        actualChanges.put(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME, updatedStretchyReportId);
    }

    return actualChanges;
}

From source file:com.gst.portfolio.floatingrates.domain.FloatingRatePeriod.java

License:Apache License

public FloatingRatePeriodData toData(final FloatingRateDTO floatingRateDTO) {

    BigDecimal interest = getInterestRate().add(floatingRateDTO.getInterestRateDiff());
    if (isDifferentialToBaseLendingRate()) {
        interest = interest.add(floatingRateDTO.fetchBaseRate(fetchFromDate()));
    }/*from  w w  w .  j  ava 2 s  . c om*/

    final LocalDate fromDate = new LocalDateTime(getFromDate()).toLocalDate();
    final LocalDate createdOn = new LocalDateTime(getCreatedOn()).toLocalDate();
    final LocalDate modidiedOn = new LocalDateTime(getModifiedOn()).toLocalDate();

    return new FloatingRatePeriodData(getId(), fromDate, interest, isDifferentialToBaseLendingRate(),
            isActive(), getCreatedBy().getUsername(), createdOn, getModifiedBy().getUsername(), modidiedOn);
}

From source file:com.gst.portfolio.loanaccount.domain.LoanTransaction.java

License:Apache License

public static LoanTransaction copyTransactionProperties(final LoanTransaction loanTransaction) {
    return new LoanTransaction(loanTransaction.loan, loanTransaction.office, loanTransaction.typeOf,
            loanTransaction.dateOf, loanTransaction.amount, loanTransaction.principalPortion,
            loanTransaction.interestPortion, loanTransaction.feeChargesPortion,
            loanTransaction.penaltyChargesPortion, loanTransaction.overPaymentPortion, loanTransaction.reversed,
            loanTransaction.paymentDetail, loanTransaction.externalId,
            new LocalDateTime(loanTransaction.createdDate), loanTransaction.appUser);
}

From source file:com.gst.portfolio.loanaccount.domain.LoanTransaction.java

License:Apache License

public LocalDateTime getCreatedDateTime() {
    return new LocalDateTime(this.createdDate);
}

From source file:com.heisenberg.mongo.MongoCollection.java

License:Apache License

protected LocalDateTime readTime(BasicDBObject dbObject, String fieldName) {
    Date date = (Date) dbObject.get(fieldName);
    return (date != null ? new LocalDateTime(date) : null);
}

From source file:com.helger.datetime.PDTFactory.java

License:Apache License

@Nonnull
public static LocalDateTime getCurrentLocalDateTime() {
    return new LocalDateTime(getLocalChronology());
}