List of usage examples for org.joda.time DateTime toLocalDateTime
public LocalDateTime toLocalDateTime()
LocalDateTime
with the same datetime and chronology. From source file:org.jadira.usertype.dateandtime.joda.AbstractMultiColumnDateTime.java
License:Apache License
@Override protected Object[] toConvertedColumns(DateTime value) { return new Object[] { value.toLocalDateTime(), value.getZone() }; }
From source file:org.jadira.usertype.dateandtime.joda.columnmapper.TimestampColumnLocalDateTimeMapper.java
License:Apache License
@Override public LocalDateTime fromNonNullValue(Timestamp value) { DateTime dateTime = new DateTime(value.getTime()); LocalDateTime localDateTime = dateTime.toLocalDateTime(); return localDateTime; }
From source file:org.jadira.usertype.dateandtime.joda.PersistentDateTimeAndZone.java
License:Apache License
@Override protected Object[] toConvertedColumns(DateTime value) { final DateTime myValue; if (databaseZone == null) { myValue = value;/*w w w . jav a 2s . c o m*/ } else { myValue = value.withZone(databaseZone); } return new Object[] { myValue.toLocalDateTime(), value.getZone() }; }
From source file:org.jadira.usertype.dateandtime.joda.PersistentDateTimeAndZoneWithOffset.java
License:Apache License
@Override protected Object[] toConvertedColumns(DateTime value) { final DateTime myValue; if (databaseZone == null) { myValue = value;//from w w w. j ava 2s .c o m } else { myValue = value.withZone(databaseZone); } return new Object[] { myValue.toLocalDateTime(), new DateTimeZoneWithOffset(value.getZone(), value.getZone().isFixed() ? null : DateTimeZone.forOffsetMillis(value.getZone().getOffset(value))) }; }
From source file:org.jraf.irondad.handler.countdown.CountDownHandler.java
License:Open Source License
private String getReply(String eventDateStr) { DateTime eventDateTime = DateTime.parse(eventDateStr); DateTime nowDateTime = DateTime.now(); String res = null;/*from w w w .j av a 2 s . co m*/ int nbDays = Days.daysBetween(nowDateTime.toLocalDateTime().toDateTime().withTimeAtStartOfDay(), eventDateTime.toLocalDateTime().toDateTime().withTimeAtStartOfDay()).getDays(); if (nbDays > 2) { res = "Dans " + nbDays + " jours !"; } else if (nbDays == 2) { res = "APRS-DEMAIN !!!"; } else if (nbDays == 1) { res = "DEMAIN !!!!!!"; } else if (nbDays == 0) { int nbHours = Hours.hoursBetween(nowDateTime, eventDateTime).getHours(); if (nbHours > 0) { if (nbHours == 1) res = "Dans " + nbHours + " heure (et quelques) !!"; else res = "Dans " + nbHours + " heures (et quelques) !"; } else if (nbHours < 0) { res = "C'est en ce moment."; } else { int nbMinutes = Minutes.minutesBetween(nowDateTime, eventDateTime).getMinutes(); if (nbMinutes > 0) { if (nbMinutes == 1) res = "Dans 1 minute !!!"; else res = "Dans " + nbMinutes + " minutes !!"; } else if (nbMinutes < 0) { res = "C'est en ce moment mme !!!!!"; } else { int nbSeconds = Seconds.secondsBetween(nowDateTime, eventDateTime).getSeconds(); if (nbSeconds > 0) res = "Dans " + nbSeconds + " secondes !!!!"; else if (nbSeconds < 0) res = "a commence !!!!!"; else res = "C'est commenc !!!!!"; } } } else if (nbDays == -1) { res = "C'est en ce moment..."; } else { res = "C'est fini :("; } return res; }
From source file:org.kuali.kpme.tklm.time.timesummary.service.TimeSummaryServiceImpl.java
License:Educational Community License
/** * Generate a list of string describing this pay calendar entry for the summary * @param payCalEntry/*from w ww .ja v a 2 s. com*/ * @return */ protected List<String> getSummaryHeader(CalendarEntry payCalEntry) { List<String> summaryHeader = new ArrayList<String>(); int dayCount = 0; DateTime beginDateTime = payCalEntry.getBeginPeriodFullDateTime(); DateTime endDateTime = payCalEntry.getEndPeriodFullDateTime(); boolean virtualDays = false; LocalDateTime endDate = payCalEntry.getEndPeriodLocalDateTime(); if (endDate.get(DateTimeFieldType.hourOfDay()) != 0 || endDate.get(DateTimeFieldType.minuteOfHour()) != 0 || endDate.get(DateTimeFieldType.secondOfMinute()) != 0) { virtualDays = true; } DateTime currentDateTime = beginDateTime; while (currentDateTime.isBefore(endDateTime)) { LocalDateTime currDate = currentDateTime.toLocalDateTime(); summaryHeader.add(makeHeaderDiplayString(currDate, virtualDays)); dayCount++; if ((dayCount % 7) == 0) { summaryHeader.add("Week " + ((dayCount / 7))); } currentDateTime = currentDateTime.plusDays(1); } summaryHeader.add("Period Total"); return summaryHeader; }
From source file:org.netxilia.api.utils.DateUtils.java
License:Open Source License
/** * // w ww . j av a2 s . co m * @param formatter * @param text * @return the ReadablePartial corresponding to the given formatter and text */ public static ReadablePartial parsePartial(DateTimeFormatter formatter, String text) { PartialDateTimeParserBucket bucket = new PartialDateTimeParserBucket(); int newPos = formatter.getParser().parseInto(bucket, text, 0); if (newPos >= 0 && newPos >= text.length()) { long millis = bucket.computeMillis(true, text); DateTime dt = new DateTime(millis, (Chronology) null); if (bucket.isHasDate() && bucket.isHasTime()) { return dt.toLocalDateTime(); } if (bucket.isHasDate()) { return dt.toLocalDate(); } return dt.toLocalTime(); } throw new IllegalArgumentException("Cannot parse date:" + text); }
From source file:org.netxilia.impexp.impl.ExcelImportService.java
License:Open Source License
private ICellCommand copyCell(Cell poiCell, CellReference cellReference, HSSFPalette palette, NetxiliaStyleResolver styleResolver) throws FormulaParsingException { CellStyle poiStyle = poiCell.getCellStyle(); Styles styles = PoiUtils.poiStyle2Netxilia(poiStyle, poiCell.getSheet().getWorkbook().getFontAt(poiStyle.getFontIndex()), palette, styleResolver); IGenericValue value = null;//from w ww . jav a 2s .co m Formula formula = null; // log.info("CELL TYPE:" + cellReference + " type:" + poiCell.getCellType() + " " // + (poiCell.getCellType() == Cell.CELL_TYPE_FORMULA ? poiCell.getCellFormula() : "no")); switch (poiCell.getCellType()) { // TODO translate errors case Cell.CELL_TYPE_STRING: value = new StringValue(poiCell.getStringCellValue()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(poiCell)) { DateTime dt = new DateTime(poiCell.getDateCellValue()); // TODO decide whether is date or time if (dt.isBefore(EXCEL_START)) { value = new DateValue(dt.toLocalTime()); } else if (dt.getMillisOfDay() == 0) { value = new DateValue(dt.toLocalDate()); } else { value = new DateValue(dt.toLocalDateTime()); } } else { value = new NumberValue(poiCell.getNumericCellValue()); } break; case Cell.CELL_TYPE_BOOLEAN: value = new BooleanValue(poiCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_FORMULA: if (poiCell.getCellFormula() != null) { formula = formulaParser.parseFormula(new Formula("=" + poiCell.getCellFormula())); } break; } if ((styles == null || styles.getItems().isEmpty()) && formula == null && (value == null || value.equals(GenericValueUtils.EMTPY_STRING))) { return null; } return CellCommands.cell(new AreaReference(cellReference), value, formula, styles); }
From source file:org.pidome.server.services.events.CustomEvent.java
protected final void occur(String reason) { DateTime date = new DateTime(); this.lastOccurrence = date.toLocalDateTime().toString(); this.lastOccurrenceDescription = reason; LOG.info("Occurrence of {} at {} because of {}", this.getIdentifier(), this.lastOccurrence, this.lastOccurrenceDescription); Map<String, Object> sendObject = new HashMap<>(); sendObject.put("id", id); sendObject.put("identifier", identifier); sendObject.put("datetime", lastOccurrence); sendObject.put("reason", reason); Runnable run = () -> {/*from w w w .j a v a 2 s . c o m*/ ClientMessenger.send("EventService", "eventOccurred", 0, sendObject); try (Connection fileDBConnection = DB.getConnection(DB.DB_SYSTEM)) { try (PreparedStatement prep = fileDBConnection.prepareStatement( "UPDATE customevents SET 'last_occurrence'=datetime('now'),'last_occurrence_remark'=? where id=?")) { prep.setString(1, reason); prep.setInt(2, id); prep.executeUpdate(); } catch (Exception ex) { LOG.error("Problem updating custom event occurrence {}", ex.getMessage()); } } catch (SQLException ex) { LOG.error("Problem updating custom event occurrence {}", ex.getMessage()); } }; new Thread() { @Override public void run() { run.run(); } }.start(); }
From source file:org.pidome.server.services.macros.Macro.java
License:Apache License
/** * Returns the last occurrence of the actions taken. * @return /* w ww .ja v a 2 s . c o m*/ */ public final String getLastOccurrence() { if (lastOccurrenceTime == 0) { return "Never"; } else { DateTime dt = new DateTime(new Date(lastOccurrenceTime)); LocalDateTime ldt = dt.toLocalDateTime(); return TimeUtils.compose24Hours(ldt.getHourOfDay(), ldt.getMinuteOfHour()) + " " + TimeUtils.composeDDMMYYYYDate(ldt.getDayOfMonth(), ldt.getMonthOfYear(), ldt.getYear()); } }