Example usage for org.joda.time LocalDate toDate

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

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public Date toDate() 

Source Link

Document

Get the date time as a java.util.Date.

Usage

From source file:de.iteratec.iteraplan.model.attribute.Timeseries.java

License:Open Source License

public TimeseriesEntry getLatestEntry() {
    if (values.isEmpty()) {
        return null;
    }/* w ww  .j  a v a 2 s.c  o m*/

    LocalDate latestDate = new LocalDate(0);
    for (LocalDate date : values.keySet()) {
        if (latestDate.isBefore(date)) {
            latestDate = date;
        }
    }
    return new TimeseriesEntry(latestDate.toDate(), values.get(latestDate));
}

From source file:de.jpaw.bonaparte.poi.BaseExcelComposer.java

License:Apache License

@Override
public void addField(TemporalElementaryDataItem di, LocalDate t) {
    if (t != null) {
        newCell(di, csDay).setCellValue(t.toDate());
    } else {/* w ww  .j  ava  2s  .  c  om*/
        writeNull(di);
    }
}

From source file:de.jpaw.bonaparte.util.DayTime.java

License:Apache License

/** Provides functionality to convert a Joda date to a GregorianCalendar. */
static public GregorianCalendar toCalendar(LocalDate when) {
    if (when == null) {
        return null;
    }//from   w  w  w .  j a  va  2s  . com
    GregorianCalendar then = new GregorianCalendar();
    then.setTime(when.toDate());
    return then;
}

From source file:de.jpaw.bonaparte.util.DayTime.java

License:Apache License

/** Provides functionality to convert a Joda date to a java Date. */
static public Date toDate(LocalDate when) {
    if (when == null) {
        return null;
    }//from  w  w  w.  j  av a 2s . c  om
    return when.toDate();
}

From source file:de.sub.goobi.persistence.managers.ProcessMysqlHelper.java

License:Open Source License

private static Batch convertBatch(ResultSet rs) throws SQLException {
    Batch batch = new Batch();
    batch.setBatchId(rs.getInt("id"));
    batch.setBatchName(rs.getString("batchName"));
    Timestamp start = rs.getTimestamp("startDate");
    if (start != null) {
        LocalDate localDate = new LocalDate(start);

        batch.setStartDate(localDate.toDate());
    }//from   www .  j  a va2  s. co m
    Timestamp end = rs.getTimestamp("endDate");
    if (end != null) {
        LocalDate localDate = new LocalDate(end);
        batch.setEndDate(localDate.toDate());
    }
    return batch;
}

From source file:de.symeda.sormas.api.utils.DateHelper.java

License:Open Source License

/**
 * requries joda-time/*from w  ww .  j a va 2 s .  co  m*/
 * 
 * <table>
 * <tr>
 * <td>90</td>
 * <td>-&gt;</td>
 * <td>[1/1/1990, 1/1/1991)</td>
 * </tr>
 * <tr>
 * <td>08</td>
 * <td>-&gt;</td>
 * <td>[1/1/2008, 1/1/2009)</td>
 * </tr>
 * <tr>
 * <td>1830</td>
 * <td>-&gt;</td>
 * <td>[1/1/1830, 1/1/1831)</td>
 * </tr>
 * <tr>
 * <td>3.01</td>
 * <td>-&gt;</td>
 * <td>[1/3/2001, 1/4/2001)</td>
 * </tr>
 * <tr>
 * <td>3.</td>
 * <td>-&gt;</td>
 * <td>[1/3/THIS_YEAR, 1/4/THIS_YEAR)</td>
 * </tr>
 * <tr>
 * <td>3.4.2012</td>
 * <td>-&gt;</td>
 * <td>[3/4/2012, 4/4/2012)</td>
 * </tr>
 * <tr>
 * <td>3.4.</td>
 * <td>-&gt;</td>
 * <td>[3/4/THIS_YEAR, 4/4/THIS_YEAR)</td>
 * </tr>
 * </table>
 * 
 * @param name
 * @param value
 * @return
 */
public static Date[] findDateBounds(String value) {

    if (value == null || value.length() < 2)
        return null;

    int day = -1;
    int month = -1;
    int year = -1;

    Matcher matcher = COMPLETE_DATE_PATTERN.matcher(value);
    if (matcher.matches()) {
        day = Integer.parseInt(matcher.group(1));
        month = Integer.parseInt(matcher.group(3));
        year = Integer.parseInt(matcher.group(5));
    } else {
        matcher = DAY_MONTH_DATE_PATTERN.matcher(value);
        if (matcher.matches()) {
            day = Integer.parseInt(matcher.group(1));
            month = Integer.parseInt(matcher.group(3));
        } else {
            matcher = MONTH_YEAR_DATE_PATTERN.matcher(value);
            if (matcher.matches()) {
                month = Integer.parseInt(matcher.group(1));
                year = Integer.parseInt(matcher.group(3));
            } else {
                matcher = MONTH_DATE_PATTERN.matcher(value);
                if (matcher.matches()) {
                    month = Integer.parseInt(matcher.group(1));
                } else {
                    matcher = DAY_DATE_PATTERN.matcher(value);
                    if (matcher.matches()) {
                        day = Integer.parseInt(matcher.group(1));
                    } else {
                        matcher = YEAR_DATE_PATTERN.matcher(value);
                        if (matcher.matches()) {
                            year = Integer.parseInt(matcher.group(1));
                        } else
                            return null;
                    }
                }
            }
        }
    }

    int thisYear = DateTime.now().year().get();
    if (year == -1) {
        year = thisYear;
    } else if (year < 100) {
        int thisYearDigits = thisYear % 100;
        int thisCentury = thisYear - thisYearDigits;
        if (year < thisYearDigits + 20)
            year += thisCentury;
        else
            year += thisCentury - 100;
    }

    LocalDate start = new LocalDate(year, 1, 1);
    LocalDate end = new LocalDate(year, 1, 1);

    if (month == -1)
        end = end.plusMonths(11);
    else {
        start = start.plusMonths(month - 1);
        end = end.plusMonths(month - 1);
    }
    if (day == -1) {
        end = end.plusMonths(1);
    } else {
        start = start.plusDays(day - 1);
        end = end.plusDays(day);
    }

    return new Date[] { start.toDate(), end.toDate() };
}

From source file:de.tshw.worktracker.dao.WorkLogEntryDAO.java

License:MIT License

public List<WorkLogEntry> findByDay(LocalDate day) {
    List<WorkLogEntry> entries = new ArrayList<>();
    try {//from   w  ww  . java  2 s.  c  o  m
        Connection connection = getDbProvider().getDatabaseConnection();
        PreparedStatement statement = connection.prepareStatement(getSelectByDayStatement());
        statement.setDate(1, new Date(day.toDate().getTime()));
        statement.setDate(2, new Date(day.toDate().getTime()));
        ResultSet result = statement.executeQuery();
        while (result.next()) {
            WorkLogEntry entry = getEntityFromResultSet(result);
            entries.add(entry);
        }
    } catch (Exception ex) {
        System.err.println("Failed to retrieve WorkLogEntries by day (Error: " + ex.getMessage() + ")");
    }
    return entries;
}

From source file:eds.entity.file.SecaFileEntity.java

/** ============= Methods inherited from EDS ============================
@Override/*from   w  w w.j a v a 2  s . c  o  m*/
        
public Object key() {
return this.getFILENAME();
}
        
@Override*/
public void randInit() {
    DateMidnight dm = new DateMidnight();
    LocalDate ld = new LocalDate();
    java.sql.Date sqlDate = new java.sql.Date(ld.toDate().getTime());
    int user = (int) (Math.random() * 12345);
    if (Math.random() > 0.5)
        this.setUPLOAD_STATUS(FILE_STATUS.COMPLETED);
    else
        this.setUPLOAD_STATUS(FILE_STATUS.INCOMPLETE);
    int filename = (user + 6) / 7;

    this.setFILENAME("File " + filename);
    this.setCREATED_BY("User " + user);
}

From source file:energy.usef.agr.model.ConnectionForecastSnapshot.java

License:Apache License

public void setPtuDate(LocalDate ptuDate) {
    if (ptuDate == null) {
        this.ptuDate = null;
    } else {/*from  w w w  .  j av a2  s  .c o m*/
        this.ptuDate = ptuDate.toDateMidnight().toDate();
    }
}

From source file:energy.usef.agr.model.DeviceRequest.java

License:Apache License

public void setPeriod(LocalDate period) {
    if (period == null) {
        this.period = null;
    } else {/* w  w  w . j a  va  2 s  .  c  om*/
        this.period = period.toDateMidnight().toDate();
    }
}