Java Code Examples for org.joda.time.LocalDateTime#toDateTime()
The following examples show how to use
org.joda.time.LocalDateTime#toDateTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelfServiceDataSetCRUD.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
private boolean isATimestamp(JSONObject jsonConf, IDataStore dataStore, int columnIndex) throws JSONException { String timestampFormat = jsonConf.get(DataSetConstants.FILE_TIMESTAMP_FORMAT).toString(); for (int i = 0; i < Math.min(10, dataStore.getRecordsCount()); i++) { IRecord record = dataStore.getRecordAt(i); IField field = record.getFieldAt(columnIndex); Object value = field.getValue(); if (value instanceof Timestamp) { continue; } try { DateTimeFormatter formatter = DateTimeFormat.forPattern(timestampFormat); LocalDateTime localDatetime = LocalDateTime.parse(value.toString(), formatter); localDatetime.toDateTime(); } catch (Exception e) { logger.debug(field.getValue() + " is not a timestamp"); return false; } } return true; }
Example 2
Source File: PersistentDateTimeWithZone.java From jadira with Apache License 2.0 | 6 votes |
@Override protected DateTime fromConvertedColumns(Object[] convertedColumns) { LocalDateTime datePart = (LocalDateTime) convertedColumns[0]; DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1]; DateTime result; if (datePart == null) { result = null; } else { result = datePart.toDateTime(offset.getStandardDateTimeZone()); } // Handling DST rollover if (result != null && offset.getOffsetDateTimeZone() != null && offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) { return result.withLaterOffsetAtOverlap(); } return result; }
Example 3
Source File: PersistentDateTimeAndZone.java From jadira with Apache License 2.0 | 6 votes |
@Override protected DateTime fromConvertedColumns(Object[] convertedColumns) { LocalDateTime datePart = (LocalDateTime) convertedColumns[0]; DateTimeZone zone = (DateTimeZone) convertedColumns[1]; DateTime result; if (datePart == null) { result = null; } else { result = datePart.toDateTime(zone); } return result; }
Example 4
Source File: PersistentDateTimeAsString.java From jadira with Apache License 2.0 | 6 votes |
@Override protected DateTime fromConvertedColumns(Object[] convertedColumns) { LocalDateTime datePart = (LocalDateTime) convertedColumns[0]; DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1]; DateTime result; if (datePart == null) { result = null; } else { result = datePart.toDateTime(offset.getStandardDateTimeZone()); } // Handling DST rollover if (result != null && offset.getOffsetDateTimeZone() != null && offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) { return result.withLaterOffsetAtOverlap(); } return result; }
Example 5
Source File: PersistentDateTimeAndZoneWithOffset.java From jadira with Apache License 2.0 | 6 votes |
@Override protected DateTime fromConvertedColumns(Object[] convertedColumns) { LocalDateTime datePart = (LocalDateTime) convertedColumns[0]; DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1]; DateTime result; if (datePart == null) { result = null; } else { result = datePart.toDateTime(offset.getStandardDateTimeZone()); } // Handling DST rollover if (result != null && offset.getOffsetDateTimeZone() != null && offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) { return result.withLaterOffsetAtOverlap(); } return result; }
Example 6
Source File: ProgressThread.java From actframework with Apache License 2.0 | 5 votes |
void refresh() { consoleStream.print("\r"); LocalDateTime currTime = LocalDateTime.now(); Duration elapsed = new Duration(progress.startTime.toDateTime(DateTimeZone.UTC), currTime.toDateTime(DateTimeZone.UTC)); String prefix = progress.task + " " + percentage() + " " + style.leftBracket; int maxSuffixLength = Math.max(0, consoleWidth - consoleRightMargin - prefix.length() - 10); String suffix = style.rightBracket + " " + ratio() + " (" + Util.formatDuration(elapsed) + " / " + eta(elapsed) + ") " + progress.extraMessage; if (suffix.length() > maxSuffixLength) suffix = suffix.substring(0, maxSuffixLength); length = consoleWidth - consoleRightMargin - prefix.length() - suffix.length(); StringBuilder sb = new StringBuilder(); sb.append(prefix); // case of indefinite progress bars if (progress.indefinite) { int pos = (int)(progress.current % length); sb.append(Util.repeat(style.space, pos)); sb.append(style.block); sb.append(Util.repeat(style.space, length - pos - 1)); } // case of definite progress bars else { sb.append(Util.repeat(style.block, progressIntegralPart())); if (progress.current < progress.max) { sb.append(style.fractionSymbols.charAt(progressFractionalPart())); sb.append(Util.repeat(style.space, length - progressIntegralPart() - 1)); } } sb.append(suffix); String line = sb.toString(); consoleStream.print(line); }
Example 7
Source File: TimestampColumnLocalDateTimeMapper.java From jadira with Apache License 2.0 | 5 votes |
@Override public Timestamp toNonNullValue(LocalDateTime value) { DateTime zonedValue = value.toDateTime(value.toDateTime()); final Timestamp timestamp = new Timestamp(zonedValue.getMillis()); return timestamp; }
Example 8
Source File: DateTimes.java From dremio-oss with Apache License 2.0 | 4 votes |
public static DateTime toDateTime(LocalDateTime localDateTime) { return localDateTime.toDateTime(DateTimeZone.UTC); }