本文整理匯總了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;
}