本文整理汇总了Java中org.joda.time.DateTime类的典型用法代码示例。如果您正苦于以下问题:Java DateTime类的具体用法?Java DateTime怎么用?Java DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateTime类属于org.joda.time包,在下文中一共展示了DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterCurrentYearItems
import org.joda.time.DateTime; //导入依赖的package包/类
private List<GameHarvest> filterCurrentYearItems(List<GameHarvest> items) {
List<GameHarvest> filtered = new ArrayList<>();
DateTime startDate = DateTimeUtils.getHuntingYearStart(mCalendarYear);
DateTime endDate = DateTimeUtils.getHuntingYearEnd(mCalendarYear);
for (GameHarvest event : items) {
DateTime eventTime = new DateTime(event.mTime);
if (LogEventBase.TYPE_SRVA.equals(event.mType)) {
if (eventTime.getYear() == mCalendarYear) {
filtered.add(event);
}
} else {
if (eventTime.isAfter(startDate) && eventTime.isBefore(endDate)) {
filtered.add(event);
}
}
}
return filtered;
}
示例2: create
import org.joda.time.DateTime; //导入依赖的package包/类
public void create(String title, File imgsDir, File output) throws IOException {
timestamp = DateTimeFormat.forPattern("yyyy-MM-dd'T'hh:mm:ssSZZ").print(DateTime.now());
uuid = UUID.randomUUID().toString();
this.title = title;
this.imgsDir = imgsDir;
try {
basedir = File.createTempFile(uuid,"");
basedir.delete();
basedir.mkdirs();
} catch (IOException e) {
e.printStackTrace();
}
classLoader = getClass().getClassLoader();
copyImages();
copyStandardFilez();
createOPFFile();
createIndex();
createTitlePage();
createTOC();
pack(basedir.getAbsolutePath(), output.getAbsolutePath());
FileUtils.deleteDirectory(basedir);
}
示例3: build
import org.joda.time.DateTime; //导入依赖的package包/类
public AuthnRequest build(LevelOfAssurance levelOfAssurance, String serviceEntityId) {
AuthnRequest authnRequest = new AuthnRequestBuilder().buildObject();
authnRequest.setID(String.format("_%s", UUID.randomUUID()));
authnRequest.setIssueInstant(DateTime.now());
authnRequest.setForceAuthn(false);
authnRequest.setDestination(destination.toString());
authnRequest.setExtensions(createExtensions());
Issuer issuer = new IssuerBuilder().buildObject();
issuer.setValue(serviceEntityId);
authnRequest.setIssuer(issuer);
authnRequest.setSignature(createSignature());
try {
XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(authnRequest).marshall(authnRequest);
Signer.signObject(authnRequest.getSignature());
} catch (SignatureException | MarshallingException e) {
throw new SAMLRuntimeException("Unknown problem while signing SAML object", e);
}
return authnRequest;
}
示例4: init
import org.joda.time.DateTime; //导入依赖的package包/类
private void init() {
Log.i(TAG, "init: fetched");
try {
Document document = Jsoup.connect(game.getLeagueType().getBaseScoreUrl() + DateUtils.getDate(game.getGameAddDate(), "yyyy-MM-dd") + "/json")
.timeout(60 * 1000)
.maxBodySize(0)
.header("Accept", "text/javascript")
.ignoreContentType(true)
.get();
SofaScoreJson espnJson = new Gson().fromJson(document.text(), SofaScoreJson.class);
for (Event event : espnJson.getEvents()) {
if (gameStatusMap.contains(event)) {
gameStatusMap.remove(event);
}
gameStatusMap.add(event);
}
MultiProcessPreference.getDefaultSharedPreferences().edit().putLong(LAST_UPDATE, new DateTime().getMillis()).commit();
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: isServiceAccessAllowed
import org.joda.time.DateTime; //导入依赖的package包/类
@Override
public boolean isServiceAccessAllowed() {
final DateTime now = DateTime.now();
if (this.startingDateTime != null) {
final DateTime st = DateTime.parse(this.startingDateTime);
if (now.isBefore(st)) {
LOGGER.warn("Service access not allowed because it starts at {}. Now is {}",
this.startingDateTime, now);
return false;
}
}
if (this.endingDateTime != null) {
final DateTime et = DateTime.parse(this.endingDateTime);
if (now.isAfter(et)) {
LOGGER.warn("Service access not allowed because it ended at {}. Now is {}",
this.endingDateTime, now);
return false;
}
}
return super.isServiceAccessAllowed();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:TimeBasedRegisteredServiceAccessStrategy.java
示例6: createReceive
import org.joda.time.DateTime; //导入依赖的package包/类
@Override
public Receive createReceive() {
return receiveBuilder().match(String.class, s -> {
Logger.debug("{}: Running no-show check ...", getClass().getCanonicalName());
DateTime now = AppUtil.adjustDST(DateTime.now());
List<Reservation> reservations = Ebean.find(Reservation.class)
.fetch("enrolment")
.fetch("enrolment.exam")
.fetch("enrolment.externalExam")
.where()
.eq("noShow", false)
.lt("endAt", now.toDate())
.isNull("externalReservation")
.findList();
if (reservations.isEmpty()) {
Logger.debug("{}: ... none found.", getClass().getCanonicalName());
} else {
handler.handleNoShows(reservations);
}
}).build();
}
示例7: ShowFilesCommandResult
import org.joda.time.DateTime; //导入依赖的package包/类
public ShowFilesCommandResult(String name,
boolean isDirectory,
boolean isFile,
long length,
String owner,
String group,
String permissions,
long accessTime,
long modificationTime) {
this.name = name;
this.isDirectory = isDirectory;
this.isFile = isFile;
this.length = length;
this.owner = owner;
this.group = group;
this.permissions = permissions;
// Get the timestamp in UTC because Drill's internal TIMESTAMP stores time in UTC
DateTime at = new DateTime(accessTime).withZoneRetainFields(DateTimeZone.UTC);
this.accessTime = new Timestamp(at.getMillis());
DateTime mt = new DateTime(modificationTime).withZoneRetainFields(DateTimeZone.UTC);
this.modificationTime = new Timestamp(mt.getMillis());
}
示例8: convert
import org.joda.time.DateTime; //导入依赖的package包/类
private BitcoinCurse convert(Response raw) {
final Double coin = 1d;
Double euro = 0d;
Matcher matcher = MONEY_PATTERN.matcher(raw.price_eur);
if(matcher.find()) {
final String rawEuro = matcher.group(1)
.replace(".", ";")
.replace(",", ".")
.replace(";", "");
euro = Double.parseDouble(rawEuro);
}
final DateTime date = DateTimeFormat.forPattern("dd.MM.yy HH:mm").parseDateTime(raw.date_de);
return new BitcoinCurse(date, coin, euro);
}
示例9: init
import org.joda.time.DateTime; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
monthDateTime = new DateTime();
layoutResId = R.layout.calendar_view;
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomizableCalendar);
if (typedArray != null) {
layoutResId = typedArray.getResourceId(R.styleable.CustomizableCalendar_month_layout, R.layout.calendar_view);
dayLayoutResId = typedArray.getResourceId(R.styleable.CustomizableCalendar_cell_layout, R.layout.calendar_cell);
typedArray.recycle();
}
}
示例10: parseDateString
import org.joda.time.DateTime; //导入依赖的package包/类
public static DateTime parseDateString(DateTimeFormatter formatter, String s) {
DateTime result = null;
try {
result = formatter.parseDateTime(s);
} catch (Exception e) {
result = null;
}
return result;
}
示例11: createMultipleExtensionsNetwork
import org.joda.time.DateTime; //导入依赖的package包/类
private Network createMultipleExtensionsNetwork() {
Network network = NetworkFactory.create("test", "test");
network.setCaseDate(DateTime.parse("2017-11-17T12:00:00+01:00"));
Substation s = network.newSubstation()
.setId("S")
.setCountry(Country.FR)
.add();
VoltageLevel vl = s.newVoltageLevel()
.setId("VL")
.setTopologyKind(TopologyKind.BUS_BREAKER)
.setNominalV(20.0f)
.setLowVoltageLimit(15.0f)
.setHighVoltageLimit(25.0f)
.add();
vl.getBusBreakerView().newBus()
.setId("BUS")
.add();
Load load = vl.newLoad()
.setId("LOAD")
.setP0(0.0f)
.setQ0(0.0f)
.setBus("BUS")
.setConnectableBus("BUS")
.add();
load.addExtension(LoadFooExt.class, new LoadFooExt(load));
load.addExtension(LoadBarExt.class, new LoadBarExt(load));
return network;
}
示例12: testGetPublishIdToSnapshotFrom
import org.joda.time.DateTime; //导入依赖的package包/类
@Test
public void testGetPublishIdToSnapshotFrom() throws Exception {
String excludeInstanceId = "exclude-352768";
List<String> instanceIds = new ArrayList<>();
instanceIds.add(excludeInstanceId);
instanceIds.add(instanceId);
instanceIds.add("extra-89351");
Date dt = new Date();
DateTime originalDateTime = new DateTime(dt);
Date originalDate = originalDateTime.toDate();
DateTime originalPlusOneDateTime = originalDateTime.plusDays(1);
Date originalPlusOneDate = originalPlusOneDateTime.toDate();
when(awsHelperService.getInstanceIdsForAutoScalingGroup(
envValues.getAutoScaleGroupNameForPublish())).thenReturn(instanceIds);
Map<String, String> instanceTags1 = new HashMap<>();
instanceTags1.put(InstanceTags.SNAPSHOT_ID.getTagName(), "");
when(awsHelperService.getTags(anyString())).thenReturn(instanceTags1);
when(awsHelperService.getLaunchTime(instanceId)).thenReturn(originalDate);
when(awsHelperService.getLaunchTime("extra-89351")).thenReturn(originalPlusOneDate);
when(httpUtil.isHttpGetResponseOk(anyString())).thenReturn(true);
String resultInstanceId = aemHelperService.getPublishIdToSnapshotFrom(excludeInstanceId);
assertThat(resultInstanceId, equalTo(instanceId));
}
示例13: setGridMarker
import org.joda.time.DateTime; //导入依赖的package包/类
protected void setGridMarker(int position) {
if (data.get(position).getGameAddDate() == new DateTime(Constants.DATE.VEGAS_TIME_ZONE).withTimeAtStartOfDay().getMillis()) {
gridMarker.setText(String.valueOf(data.get(position).getGridCount()));
switch (data.get(position).getPreviousGridStatus()) {
case NEUTRAL:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorDraw));
break;
case NEGATIVE:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorError));
break;
case DRAW:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorDraw));
break;
case POSITIVE:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorAccent));
break;
default:
break;
}
} else {
switch (data.get(position).getBidResult()) {
case NEUTRAL:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white));
break;
case NEGATIVE:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorError));
break;
case DRAW:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorDraw));
break;
case POSITIVE:
gridMarker.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorAccent));
break;
default:
break;
}
gridMarker.setText("");
}
}
示例14: shouldTransformLeniently
import org.joda.time.DateTime; //导入依赖的package包/类
@Test
public void shouldTransformLeniently() {
assertThat(transformer.from("2014-06-01T12:34:56"), is(new DateTime(2014, 6, 1, 12, 34, 56).toDate()));
assertThat(transformer.from("2014-06-01T12:34"), is(new DateTime(2014, 6, 1, 12, 34, 0).toDate()));
assertThat(transformer.from("2014-06-01T12"), is(new DateTime(2014, 6, 1, 12, 0, 0).toDate()));
assertThat(transformer.from("2014-06-01"), is(new DateTime(2014, 6, 1, 0, 0, 0).toDate()));
assertThat(transformer.from("2014-06"), is(new DateTime(2014, 6, 1, 0, 0, 0).toDate()));
assertThat(transformer.from("2014"), is(new DateTime(2014, 1, 1, 0, 0, 0).toDate()));
assertThat(transformer.from("2014-06-01T12:34:56+08:00"), is(new DateTime(2014, 6, 1, 12, 34, 56).withZoneRetainFields(DateTimeZone.forOffsetHours(8)).toDate()));
assertThat(transformer.from("2014-06-01T12:34+08:00"), is(new DateTime(2014, 6, 1, 12, 34, 0).withZoneRetainFields(DateTimeZone.forOffsetHours(8)).toDate()));
assertThat(transformer.from("2014-06-01T12+08:00"), is(new DateTime(2014, 6, 1, 12, 0, 0).withZoneRetainFields(DateTimeZone.forOffsetHours(8)).toDate()));
}
示例15: processMessage
import org.joda.time.DateTime; //导入依赖的package包/类
public boolean processMessage(Message msg) {
try {
MessageProcessingResult result = null;
NotificationEvent event =
objectMapper.readValue(msg.getBody(), NotificationEvent.class);
logger.info("Receive event {} with state {} created at {}",
event.getDetail().getInstanceId(),
event.getDetail().getState(), event.getTime());
sqsEventLogger.info(objectMapper.writeValueAsString(event));
Map<String, String> attributes = msg.getAttributes();
if (attributes.containsKey("SentTimestamp")) {
DateTime sentTime = new DateTime(Long.parseLong(attributes.get("SentTimestamp")),
DateTimeZone.UTC);
event.setSqsSentTime(sentTime.toDate());
}
if (handler != null) {
result = handler.processEvent(event);
if (result != null) {
messageProcessingLogger.info(objectMapper.writeValueAsString(result));
return result.isSucceed();
}
}
} catch (Exception e) {
logger.warn("Error Process message:{}", ExceptionUtils.getRootCauseMessage(e));
}
return false;
}