Example usage for org.joda.time LocalDate toString

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

Introduction

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

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-dd).

Usage

From source file:de.dreier.mytargets.features.settings.DatePreference.java

License:Open Source License

public void persistDateValue(LocalDate value) {
    persistString(value.toString());
}

From source file:de.dreier.mytargets.features.settings.SettingsManager.java

License:Open Source License

public static void setProfileBirthDay(LocalDate birthDay) {
    preferences.edit().putString(KEY_PROFILE_BIRTHDAY, birthDay.toString()).apply();
}

From source file:de.geeksfactory.opacclient.storage.AccountDataSource.java

License:MIT License

private void putOrNull(ContentValues cv, String key, LocalDate value) {
    if (value != null) {
        cv.put(key, value.toString());
    } else {/*from w w w.j  a v  a2 s .  c  o  m*/
        cv.putNull(key);
    }
}

From source file:de.geeksfactory.opacclient.storage.AccountDataSource.java

License:MIT License

public long addAlarm(LocalDate deadline, long[] media, DateTime alarmTime) {
    for (long mid : media) {
        if (getLentItem(mid) == null) {
            throw new DataIntegrityException("Cannot add alarm with deadline " + deadline.toString()
                    + " that has dependency on the non-existing media item " + mid);
        }/* w ww.j  a v  a  2  s  .  c om*/
    }

    ContentValues values = new ContentValues();
    values.put("deadline", deadline.toString());
    values.put("media", joinLongs(media, ","));
    values.put("alarm", alarmTime.toString());
    values.put("notified", 0);
    values.put("finished", 0);
    return database.insert(AccountDatabase.TABLENAME_ALARMS, null, values);
}

From source file:de.geeksfactory.opacclient.storage.AccountDataSource.java

License:MIT License

public Alarm getAlarmByDeadline(LocalDate deadline) {
    String[] selA = { deadline.toString() };
    Cursor cursor = database.query(AccountDatabase.TABLENAME_ALARMS, AccountDatabase.COLUMNS_ALARMS,
            "deadline = ?", selA, null, null, null);
    Alarm item = null;/*ww w  .ja  va 2s  .  c om*/
    cursor.moveToFirst();
    if (!cursor.isAfterLast()) {
        item = cursorToAlarm(cursor);
        cursor.moveToNext();
    }
    // Make sure to close the cursor
    cursor.close();
    return item;
}

From source file:edu.harvard.med.screensaver.db.usertypes.LocalDateType.java

License:Open Source License

public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
    if (value == null) {
        st.setNull(index, Hibernate.DATE.sqlType());
    } else {//from   w  ww.  ja v a 2s .  c  o m
        LocalDate localDate = (LocalDate) value;
        /* This is WRONG! Fails for ranges [2008-03-09,2008-04-06] and [2008-10-26,2008-11-02], which are the dates between the old and nw Daylight Savings times!!!
        Date sqlDate = new Date(((LocalDate) value).toDateMidnight().getMillis());
         */
        Date sqlDate = Date.valueOf(localDate.toString());
        assert sqlDate.toString().equals(localDate.toString()) : "date conversion failed";
        st.setDate(index, sqlDate);
    }
}

From source file:edu.wisc.hr.demo.support.PayPeriodGenerator.java

License:Apache License

/**
 * Returns a List of pay periods, where pay periods are Strings of the form
 * "Date - Date", as in "2013-08-02 - 2013-08-16".
 * @param howMany a positive integer or zero
 * @return a List of howMany Strings representing pay periods
 * @throws IllegalArgumentException if howMany < 0
 *///from w  w  w  .jav a 2  s  .  c  om
public List<String> payPeriods(int howMany) {

    if (howMany < 0) {
        throw new IllegalArgumentException("Cannot generate negative number of pay periods.");
    }

    // if this method were expensive or frequently called we could cache results since it's the same
    // result for each call for a given howMany.  Indeed, could further optimize since howMany( N + 1) is
    // howMany( N) with an additional pay period prepended.
    //
    // compute cycles are cheap and premature optimization is

    List<String> payPeriods = new LinkedList<String>();

    int daysAgoToStart = ((PERIOD_DURATION_IN_DAYS + 2) * howMany);

    LocalDate startNextPayPeriod = new LocalDate().minusDays(daysAgoToStart);

    // TODO: calculate the exact number of days to add once and skip the loop
    while (startNextPayPeriod.getDayOfWeek() != PERIOD_START_DAY) {
        startNextPayPeriod = startNextPayPeriod.plusDays(1);
    }

    // startNextPayPeriod is now a PERIOD_START_DAY (e.g., Sunday) sufficiently long ago that
    // we can generate howMany periods from there and not quite hit today

    for (int i = 0; i < howMany; i++) {
        LocalDate startThisPayPeriod = startNextPayPeriod;
        LocalDate endThisPayPeriod = startThisPayPeriod.plusDays(PERIOD_DURATION_IN_DAYS - 1);

        // TODO: use a format string for better self-respect
        String payPeriodRepresentation = startThisPayPeriod.toString().concat(" - ")
                .concat(endThisPayPeriod.toString());

        payPeriods.add(payPeriodRepresentation);

        startNextPayPeriod = endThisPayPeriod.plusDays(1);
    }

    return payPeriods;
}

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

License:Apache License

/**
 * Transforms a {@link LocalDate} to a String (xsd:dateTime) .
 * /*from w  w  w.j  ava 2  s.  c  o  m*/
 * @param date {@link LocalDate}
 * @return String (xsd:date)
 */
public static String printDate(LocalDate date) {
    if (date == null) {
        return null;
    }
    return date.toString();
}

From source file:energy.usef.pbcfeeder.PbcFeederClient.java

License:Apache License

/**
 * Return a given amount of {@link PbcStubDataDto} in a list starting from the PtuIndex on the given
 * date./* w  ww  . j  a  v  a  2s  . c o  m*/
 *
 * @param date
 * @param ptuIndex
 * @param amount
 * @return
 */
public List<PbcStubDataDto> getPbcStubDataList(LocalDate date, int ptuIndex, int amount) {
    String pbcEndpoint = config.getProperty(ConfigPbcFeederParam.PBC_FEEDER_ENDPOINT) + "/ptu/"
            + date.toString() + "/" + ptuIndex + "/" + amount;

    String value = get(pbcEndpoint);
    ObjectMapper mapper = new ObjectMapper();

    List<PbcStubDataDto> pbcStubDataDtoList = new ArrayList<>();
    try {
        pbcStubDataDtoList = mapper.readValue(value, new TypeReference<List<PbcStubDataDto>>() {
        });
    } catch (IOException e) {
        LOGGER.error("Exception caught: {}", e);
    }
    return pbcStubDataDtoList;
}

From source file:frontEnd.userLogadoGUI.java

private void jbtnAlugarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAlugarActionPerformed
    this.setEnabled(false);
    User user = new User(jtxtfTipo.getText(), jtxtfMatricula.getText(), jtxtfNome.getText(), null);
    Livro livro = new Livro();
    alugarLivroGUI alugarLivro = new alugarLivroGUI(this);

    int row = jtbProcuraLivro.getSelectedRow();
    if (row >= 0) {
        String[] code = { jtbProcuraLivro.getValueAt(row, 0).toString(),
                jtbProcuraLivro.getValueAt(row, 1).toString(), jtbProcuraLivro.getValueAt(row, 2).toString(),
                jtbProcuraLivro.getValueAt(row, 5).toString() };

        alugarLivro.setUser(user);/*from   w ww  .  j av  a  2 s  .  c o m*/
        alugarLivro.setLivro(livro);

        LocalDate now = LocalDate.now(), next = now.plusDays(7);
        String currentDate = now.toString(), nextDate = next.toString();

        livro.setTitulo(code[0]);
        livro.setEditora(code[1]);
        livro.setAutor(code[2]);
        livro.setId(code[3]);
        livro.setEntrega(nextDate);
        livro.setAluguel(currentDate);

        alugarLivro.setVisible(true);
    } else {
        JOptionPane.showMessageDialog(rootPane, "Nenhum livro selecionado.", "Erro", JOptionPane.ERROR_MESSAGE);
    }
}