本文整理汇总了Java中org.joda.time.format.ISODateTimeFormat.dateTime方法的典型用法代码示例。如果您正苦于以下问题:Java ISODateTimeFormat.dateTime方法的具体用法?Java ISODateTimeFormat.dateTime怎么用?Java ISODateTimeFormat.dateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.format.ISODateTimeFormat
的用法示例。
在下文中一共展示了ISODateTimeFormat.dateTime方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTimestamp
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@Override
public void writeTimestamp(boolean isNull) throws IOException {
TimeStampWriter ts = writer.timeStamp();
if(!isNull){
switch (parser.getCurrentToken()) {
case VALUE_NUMBER_INT:
DateTime dt = new DateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC);
ts.writeTimeStamp(dt.getMillis());
break;
case VALUE_STRING:
DateTimeFormatter f = ISODateTimeFormat.dateTime();
ts.writeTimeStamp(DateTime.parse(parser.getValueAsString(), f).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis());
break;
default:
throw UserException.unsupportedError()
.message(parser.getCurrentToken().toString())
.build(LOG);
}
}
}
示例2: BasicJsonOutput
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
protected BasicJsonOutput(JsonGenerator gen, DateOutputFormat dateOutput) {
Preconditions.checkNotNull(dateOutput);
Preconditions.checkNotNull(gen);
this.gen = gen;
switch (dateOutput) {
case SQL: {
dateFormatter = DateUtility.formatDate;
timeFormatter = DateUtility.formatTime;
timestampFormatter = DateUtility.formatTimeStamp;
break;
}
case ISO: {
dateFormatter = ISODateTimeFormat.date();
timeFormatter = ISODateTimeFormat.time();
timestampFormatter = ISODateTimeFormat.dateTime();
break;
}
default:
throw new UnsupportedOperationException(String.format("Unable to support date output of type %s.", dateOutput));
}
}
示例3: writeTimestamp
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@Override
public void writeTimestamp(boolean isNull) throws IOException {
TimeStampMilliWriter ts = writer.timeStampMilli();
if(!isNull){
switch (parser.getCurrentToken()) {
case VALUE_NUMBER_INT:
LocalDateTime dt = new LocalDateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC);
ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(dt));
break;
case VALUE_STRING:
DateTimeFormatter f = ISODateTimeFormat.dateTime();
ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(LocalDateTime.parse(parser.getValueAsString(), f)));
break;
default:
throw UserException.unsupportedError()
.message(parser.getCurrentToken().toString())
.build(LOG);
}
}
}
示例4: checkStateAndLogIfNecessary
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
void checkStateAndLogIfNecessary() {
if (!fragmentStarted) {
final DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
if (isCancelled()) {
logger.warn("Received cancel request at {} for fragment {} that was never started",
formatter.print(cancellationTime),
QueryIdHelper.getQueryIdentifier(handle));
}
FragmentEvent event;
while ((event = finishedReceivers.poll()) != null) {
logger.warn("Received early fragment termination at {} for path {} {} -> {} for a fragment that was never started",
formatter.print(event.time),
QueryIdHelper.getQueryId(handle.getQueryId()),
QueryIdHelper.getFragmentId(event.handle),
QueryIdHelper.getFragmentId(handle)
);
}
}
}
示例5: FABPressed
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@OnClick(R.id.fab)
public void FABPressed() {
Intent result = new Intent();
currentTrip.name = jname.getText().toString();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
currentTrip.startDate = fmt.print(startDate);
currentTrip.endDate = fmt.print(endDate);
// add more code to initialize the rest of the fields
Parcelable parcel = Parcels.wrap(currentTrip);
result.putExtra("TRIP", parcel);
setResult(RESULT_OK, result);
finish();
}
示例6: createDateTimeFormatter
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
/**
* Create a new {@code DateTimeFormatter} using this factory.
* <p>If no specific pattern or style has been defined,
* the supplied {@code fallbackFormatter} will be used.
* @param fallbackFormatter the fall-back formatter to use when no specific
* factory properties have been set (can be {@code null}).
* @return a new date time formatter
*/
public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) {
DateTimeFormatter dateTimeFormatter = null;
if (StringUtils.hasLength(this.pattern)) {
dateTimeFormatter = DateTimeFormat.forPattern(this.pattern);
}
else if (this.iso != null && this.iso != ISO.NONE) {
switch (this.iso) {
case DATE:
dateTimeFormatter = ISODateTimeFormat.date();
break;
case TIME:
dateTimeFormatter = ISODateTimeFormat.time();
break;
case DATE_TIME:
dateTimeFormatter = ISODateTimeFormat.dateTime();
break;
case NONE:
/* no-op */
break;
default:
throw new IllegalStateException("Unsupported ISO format: " + this.iso);
}
}
else if (StringUtils.hasLength(this.style)) {
dateTimeFormatter = DateTimeFormat.forStyle(this.style);
}
if (dateTimeFormatter != null && this.timeZone != null) {
dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone));
}
return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter);
}
示例7: FABPressed
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@OnClick(R.id.fab)
public void FABPressed() {
Intent result = new Intent();
Trip aTrip = new Trip();
aTrip.name = jname.getText().toString();
aTrip.location = location.getText().toString();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
aTrip.startDate = fmt.print(startDate);
aTrip.endDate = fmt.print(endDate);
// add more code to initialize the rest of the fields
Parcelable parcel = Parcels.wrap(aTrip);
result.putExtra("TRIP", parcel);
setResult(RESULT_OK, result);
finish();
}
示例8: FABPressed
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@OnClick(R.id.fab)
public void FABPressed() {
Intent result = new Intent();
currentTrip.setName(jname.getText().toString());
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
currentTrip.setStartDate(fmt.print(startDate));
currentTrip.setEndDate(fmt.print(endDate));
// add more code to initialize the rest of the fields
Parcelable parcel = Parcels.wrap(currentTrip);
result.putExtra("TRIP", parcel);
setResult(RESULT_OK, result);
finish();
}
示例9: onOptionsItemSelected
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.save_media) {
switch (mediaType) {
case 1: // text
DateTime now = DateTime.now();
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
JournalEntry currentEntry = new JournalEntry();
currentEntry.setCaption(entry_caption.getText().toString());
currentEntry.setType(mediaType);
currentEntry.setLat(ALLENDALE_LAT);
currentEntry.setLng(ALLENDATE_LNG);
currentEntry.setDate(fmt.print(now));
DatabaseReference savedEntry = entriesRef.push();
savedEntry.setValue(currentEntry);
Snackbar.make(entry_caption,
"Your entry is saved",
Snackbar.LENGTH_LONG).show();
break;
case 2: // photo
uploadMedia(mediaType, "image/jpeg", "photos");
break;
case 3: // audio
uploadMedia(mediaType, "audio/m4a", "audio");
break;
case 4: // video
uploadMedia(mediaType, "video/mp4", "videos");
break;
}
return true;
}
return false;
}
示例10: FABPressed
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@OnClick(R.id.fab)
public void FABPressed() {
Intent result = new Intent();
currentTrip.setName(jname.getText().toString());
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
currentTrip.setStartDate(fmt.print(startDate));
currentTrip.setEndDate(fmt.print(endDate));
if (coverPhotoUrl != null)
currentTrip.setCoverPhotoUrl(coverPhotoUrl);
// add more code to initialize the rest of the fields
Parcelable parcel = Parcels.wrap(currentTrip);
result.putExtra("TRIP", parcel);
setResult(RESULT_OK, result);
finish();
}
示例11: combineShortSessions
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
public void combineShortSessions(ESDriver es, String user, int timeThres) throws ElasticsearchException, IOException {
BoolQueryBuilder filterSearch = new BoolQueryBuilder();
filterSearch.must(QueryBuilders.termQuery("IP", user));
String[] indexArr = new String[] { logIndex };
String[] typeArr = new String[] { cleanupType };
int docCount = es.getDocCount(indexArr, typeArr, filterSearch);
if (docCount < 3) {
deleteInvalid(es, user);
return;
}
BoolQueryBuilder filterCheck = new BoolQueryBuilder();
filterCheck.must(QueryBuilders.termQuery("IP", user)).must(QueryBuilders.termQuery("Referer", "-"));
SearchResponse checkReferer = es.getClient().prepareSearch(logIndex).setTypes(this.cleanupType).setScroll(new TimeValue(60000)).setQuery(filterCheck).setSize(0).execute().actionGet();
long numInvalid = checkReferer.getHits().getTotalHits();
double invalidRate = numInvalid / docCount;
if (invalidRate >= 0.8) {
deleteInvalid(es, user);
return;
}
StatsAggregationBuilder statsAgg = AggregationBuilders.stats("Stats").field("Time");
SearchResponse srSession = es.getClient().prepareSearch(logIndex).setTypes(this.cleanupType).setScroll(new TimeValue(60000)).setQuery(filterSearch)
.addAggregation(AggregationBuilders.terms("Sessions").field("SessionID").size(docCount).subAggregation(statsAgg)).execute().actionGet();
Terms sessions = srSession.getAggregations().get("Sessions");
List<Session> sessionList = new ArrayList<>();
for (Terms.Bucket session : sessions.getBuckets()) {
Stats agg = session.getAggregations().get("Stats");
Session sess = new Session(props, es, agg.getMinAsString(), agg.getMaxAsString(), session.getKey().toString());
sessionList.add(sess);
}
Collections.sort(sessionList);
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
String last = null;
String lastnewID = null;
String lastoldID = null;
String current = null;
for (Session s : sessionList) {
current = s.getEndTime();
if (last != null) {
if (Seconds.secondsBetween(fmt.parseDateTime(last), fmt.parseDateTime(current)).getSeconds() < timeThres) {
if (lastnewID == null) {
s.setNewID(lastoldID);
} else {
s.setNewID(lastnewID);
}
QueryBuilder fs = QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("SessionID", s.getID()));
SearchResponse scrollResp = es.getClient().prepareSearch(logIndex).setTypes(this.cleanupType).setScroll(new TimeValue(60000)).setQuery(fs).setSize(100).execute().actionGet();
while (true) {
for (SearchHit hit : scrollResp.getHits().getHits()) {
if (lastnewID == null) {
update(es, logIndex, this.cleanupType, hit.getId(), "SessionID", lastoldID);
} else {
update(es, logIndex, this.cleanupType, hit.getId(), "SessionID", lastnewID);
}
}
scrollResp = es.getClient().prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
if (scrollResp.getHits().getHits().length == 0) {
break;
}
}
}
;
}
lastoldID = s.getID();
lastnewID = s.getNewID();
last = current;
}
}
示例12: checkByRate
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
private int checkByRate(ESDriver es, String user) {
int rate = Integer.parseInt(props.getProperty("sendingrate"));
Pattern pattern = Pattern.compile("get (.*?) http/*");
Matcher matcher;
BoolQueryBuilder filterSearch = new BoolQueryBuilder();
filterSearch.must(QueryBuilders.termQuery("IP", user));
AggregationBuilder aggregation = AggregationBuilders.dateHistogram("by_minute").field("Time").dateHistogramInterval(DateHistogramInterval.MINUTE).order(Order.COUNT_DESC);
SearchResponse checkRobot = es.getClient().prepareSearch(logIndex).setTypes(httpType, ftpType).setQuery(filterSearch).setSize(0).addAggregation(aggregation).execute().actionGet();
Histogram agg = checkRobot.getAggregations().get("by_minute");
List<? extends Histogram.Bucket> botList = agg.getBuckets();
long maxCount = botList.get(0).getDocCount();
if (maxCount >= rate) {
return 0;
} else {
DateTime dt1 = null;
int toLast = 0;
SearchResponse scrollResp = es.getClient().prepareSearch(logIndex).setTypes(httpType, ftpType).setScroll(new TimeValue(60000)).setQuery(filterSearch).setSize(100).execute().actionGet();
while (true) {
for (SearchHit hit : scrollResp.getHits().getHits()) {
Map<String, Object> result = hit.getSource();
String logtype = (String) result.get("LogType");
if (logtype.equals("PO.DAAC")) {
String request = (String) result.get("Request");
matcher = pattern.matcher(request.trim().toLowerCase());
boolean find = false;
while (matcher.find()) {
request = matcher.group(1);
result.put("RequestUrl", "http://podaac.jpl.nasa.gov" + request);
find = true;
}
if (!find) {
result.put("RequestUrl", request);
}
} else {
result.put("RequestUrl", result.get("Request"));
}
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
DateTime dt2 = fmt.parseDateTime((String) result.get("Time"));
if (dt1 == null) {
toLast = 0;
} else {
toLast = Math.abs(Seconds.secondsBetween(dt1, dt2).getSeconds());
}
result.put("ToLast", toLast);
IndexRequest ir = new IndexRequest(logIndex, cleanupType).source(result);
es.getBulkProcessor().add(ir);
dt1 = dt2;
}
scrollResp = es.getClient().prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
if (scrollResp.getHits().getHits().length == 0) {
break;
}
}
}
return 1;
}