Example usage for org.joda.time LocalDateTime toString

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

Introduction

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

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS).

Usage

From source file:com.restservice.dto.CountPeaksNewsAndDate.java

License:Open Source License

/**
 * @param dates/*from w w  w.j  a va  2s .  com*/
 *            the dates to set
 */
public void setRawDate(LocalDateTime rawDate) {
    this.rawDate = rawDate;
    this.dateString = rawDate.toString();
}

From source file:com.wavemaker.commons.data.mapper.WMDateColumnLocalDateTimeMapper.java

License:Apache License

@Override
public String toNonNullString(LocalDateTime value) {
    return value.toString();
}

From source file:control.ConfigController.java

public static boolean doDailyBackup() {
    cdao = new ConfigDAO();
    if (cdao.isSetAutoBackup()) {
        dao = new GenericDAO();
        String s = dao.get("app_config", "last_backup");
        LocalDateTime hoje = new LocalDateTime(System.currentTimeMillis());
        LocalDateTime last_bkp = new LocalDateTime(s);
        Period p = new Period(hoje, last_bkp);
        if ((p.getDays() < 0) || (s == null)) {
            java.io.File file = new java.io.File(
                    System.getProperty("user.home") + System.getProperty("file.separator") + ".jbiblioteca"
                            + System.getProperty("file.separator") + "jbiblioteca_bkp.db");
            try {
                Database.backupDatabase(file);
                ConfigController.saveLastBackupDate("'" + hoje.toString() + "'");
                System.out.println("Backup \"" + file.getCanonicalPath() + "\" salvo. ");
            } catch (Exception ex) {
                Logger.getLogger(ConfigController.class.getName()).log(Level.SEVERE, null, ex);
            }/*  w  w  w  .  j  a v  a  2 s.c  om*/
            return true;
        }
    }
    return false;
}

From source file:energy.usef.core.adapter.YodaTimeAdapter.java

License:Apache License

/**
 * Transforms a {@link LocalDateTime} to a String (xsd:dateTime).
 * // w  w  w .  j  a  va2 s .  c  om
 * @param date {@link LocalDateTime}
 * @return String (xsd:dateTime)
 */
public static String printDateTime(LocalDateTime date) {
    if (date == null) {
        return null;
    }
    return date.toString();
}

From source file:energy.usef.core.service.business.IncomingMessageVerificationService.java

License:Apache License

/**
 * Checks whether the message is received.
 *
 * @param validUntil - {@link LocalDateTime} when the validity of this message ends.
 * @throws BusinessException if the {@link MessageMetadata#getMessageID()} of the message is already present in the database.
 *///  w ww  .j  a va  2 s.  c o  m
public void validateMessageValidUntil(LocalDateTime validUntil) throws BusinessException {

    if (validUntil != null && DateTimeUtil.getCurrentDateTime().isAfter(validUntil)) {
        LOGGER.warn("ValidUntil is expired: {}", validUntil.toString());
        throw new BusinessException(IncomingMessageError.MESSAGE_EXPIRED);
    }
}

From source file:femr.util.calculations.dateUtils.java

License:Open Source License

public static String getCurrentDateTimeString() {
    DateTimeFormatter dateFormat = DateTimeFormat.forPattern("yyyy/mm/dd HH:mm:ss");
    LocalDateTime localDateTime = new LocalDateTime();
    dateFormat.print(localDateTime);/*from w ww  .j  a v  a2  s  .  c  o  m*/
    String dt = localDateTime.toString();
    return dt;
}

From source file:nz.al4.airclock.TimeCalculator.java

License:Open Source License

/**
 * Calculate when to set an alarm given a LocalDateTime (no time zone information)
 *
 * To do this, we need to figure out what time zone will be applied when we hit this time...
 * far from trivial!/* ww w.  j ava 2 s  .c om*/
 *
 * So we use linear algebra to create simple formulas for the absolute time and tz offet of our
 * alarm.
 *
 * @param localAlarmTime
 * @return
 */
public DateTime timeForAlarm(LocalDateTime localAlarmTime) {
    Log.d("timeForAlarm", "Calculating alarm for time " + localAlarmTime.toString());
    // x axis, Time in ms since 1970
    long To = mOriginTime.getMillis(); // x1
    long Td = mDestTime.getMillis(); // x3
    // y axis, Offset in milliseconds
    long Oo = mOriginTime.getZone().getOffset(mOriginTime); // y1
    long Od = mDestTime.getZone().getOffset(mDestTime); // y3

    System.out.println(String.valueOf(To) + ',' + String.valueOf(Oo));
    System.out.println(String.valueOf(Td) + ',' + String.valueOf(Od));

    // slope = x/y
    float slope = (Td - To) / (Od - Oo);
    Log.v("debug", String.valueOf(slope));
    System.out.println(String.valueOf(slope));

    /*
    now that we have the slope, we can use algebra to rearrange what we know and come up
    with formulas for what we don't.
            
    * (x1, y1) is the point at takeoff, i.e (To, Oo)
    * our unknown point, the alarm point is (x2, y2) => (Ta, Oa) (Time of alarm,
      offset of alarm)
    * the localtime of the alarm we want to calculate, T, equals x2 (absolute time at
      alarm) plus y2 (offset at time of alarm)
    (tz offset at alarm time), i.e T=x2+y2
            
    by rearranging the slope formula, y2 = (x2 - x1)/S + y1
    therefore T - x2  = (x2 - x1)/S + y1 etc, until we get the formulas below
    */

    // UTC is zero offset,
    long T = localAlarmTime.toDateTime(DateTimeZone.UTC).getMillis();
    System.out.println("T " + String.valueOf(T));
    double Ta = ((slope * To) - Oo + T) / (slope + 1);
    System.out.println("Ta " + String.valueOf(Ta));
    // y2 = T - x2
    double Oa = T - Ta;
    System.out.println("Oa " + String.valueOf(Oa));

    // construct a datetime
    DateTimeZone alarmTz = DateTimeZone.forOffsetMillis((int) Oa);
    DateTime alarmTime = new DateTime((long) Ta, alarmTz);
    Log.d("timeForAlarm", "as origin: " + alarmTime.toDateTime(mOriginTime.getZone()).toString());
    Log.d("timeForAlarm", "as dest: " + alarmTime.toDateTime(mDestTime.getZone()).toString());

    return alarmTime;
}

From source file:org.alfresco.bm.devicesync.dao.mongo.MongoMetricsService.java

License:Open Source License

@Override
public void addMetrics(DBObject syncMetrics, DBObject activeMQStats) {
    long timestamp = System.currentTimeMillis();
    LocalDateTime time = new LocalDateTime(timestamp, DateTimeZone.UTC);
    String formattedTime = time.toString();

    DBObject insert = BasicDBObjectBuilder.start("timestamp", timestamp).add("time", formattedTime)
            .add("sync", syncMetrics).add("activeMQ", activeMQStats).get();
    collection.insert(insert);/*from  w w w .j  av a  2s.co m*/
}

From source file:org.apache.cayenne.joda.access.types.LocalDateTimeType.java

License:Apache License

@Override
public String toString(LocalDateTime value) {
    if (value == null) {
        return "NULL";
    }//ww w. ja  va  2s.co  m

    return '\'' + value.toString() + '\'';
}

From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java

License:Apache License

@Override
@CronTarget(jobName = JobName.UPDATE_EMAIL_OUTBOUND_WITH_CAMPAIGN_MESSAGE)
public void storeTemplateMessageIntoEmailOutBoundTable() throws JobExecutionException {
    final Collection<EmailCampaignData> emailCampaignDataCollection = this.emailCampaignReadPlatformService
            .retrieveAllScheduleActiveCampaign();
    if (emailCampaignDataCollection != null) {
        for (EmailCampaignData emailCampaignData : emailCampaignDataCollection) {
            LocalDateTime tenantDateNow = tenantDateTime();
            LocalDateTime nextTriggerDate = emailCampaignData.getNextTriggerDate().toLocalDateTime();

            logger.info(//from ww  w .j a  v a  2  s . c  o m
                    "tenant time " + tenantDateNow.toString() + " trigger time " + nextTriggerDate.toString());
            if (nextTriggerDate.isBefore(tenantDateNow)) {
                insertDirectCampaignIntoEmailOutboundTable(emailCampaignData.getParamValue(),
                        emailCampaignData.getEmailSubject(), emailCampaignData.getMessage(),
                        emailCampaignData.getCampaignName(), emailCampaignData.getId());
                this.updateTriggerDates(emailCampaignData.getId());
            }
        }
    }
}