本文整理了Java中org.apache.brooklyn.util.time.Time.makeDateString()
方法的一些代码示例,展示了Time.makeDateString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.makeDateString()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:makeDateString
[英]as #makeDateString(Date) for current date/time
[中]作为当前日期/时间的#makeDateString(日期)
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** returns the time in {@value #DATE_FORMAT_PREFERRED} format for the given date;
* this format is numeric big-endian but otherwise optimized for people to read, with spaces and colons and dots;
* time is local to the server and time zone is <i>not</i> included */
public static String makeDateString(Date date) {
return makeDateString(date, DATE_FORMAT_PREFERRED);
}
/** as {@link #makeDateString(Date, String, TimeZone)} for the local time zone */
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** as {@link #makeDateString(Date, String, TimeZone)} for the local time zone */
public static String makeDateString(Date date, String format) {
return makeDateString(date, format, null);
}
/** as {@link #makeDateString(Date, String, TimeZone)} for the given time zone; consider {@link TimeZone#GMT} */
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
private String format(Date date) {
return Time.makeDateString(date, Time.DATE_FORMAT_ISO8601_NO_MILLIS, Time.TIME_ZONE_UTC);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** as {@link #makeDateString(Date, String)} using {@link #DATE_FORMAT_PREFERRED_W_TZ} */
public static String makeDateString(Calendar date) {
return makeDateString(date.getTime(), DATE_FORMAT_PREFERRED_W_TZ);
}
/** as {@link #makeDateString(Date, String, TimeZone)} for the time zone of the given calendar object */
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** as {@link #makeDateString(Date)} for current date/time */
public static String makeDateString() {
return makeDateString(System.currentTimeMillis());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** as {@link #makeDateString(Date)} for long millis since UTC epock */
public static String makeDateString(long date) {
return makeDateString(new Date(date), DATE_FORMAT_PREFERRED);
}
/** returns the time in {@value #DATE_FORMAT_PREFERRED} format for the given date;
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Override
@Nullable
public String apply(@Nullable Long input) {
if (input == null) return null;
return Time.makeDateString(input);
}
};
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** as {@link #makeDateString(Date, String, TimeZone)} for the time zone of the given calendar object */
public static String makeDateString(Calendar date, String format) {
return makeDateString(date.getTime(), format, date.getTimeZone());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
private void deleteNode(String nodeId) {
getOrCreateNodeWriter(nodeId).delete();
changeLogWriter.append(Time.makeDateString()+": deleted node "+nodeId+"\n");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
public String toVerboseString() {
return MoreObjects.toStringHelper(this)
.omitNullValues()
.add("brooklynVersion", getBrooklynVersion())
.add("nodeId", getNodeId())
.add("uri", getUri())
.add("status", getStatus())
.add("priority", getPriority())
.add("localTimestamp", getLocalTimestamp()+"="+Time.makeDateString(getLocalTimestamp()))
.add("remoteTimestamp", getRemoteTimestamp()+(getRemoteTimestamp()==null ? "" :
"="+Time.makeDateString(getRemoteTimestamp())))
.toString();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-policy
protected String getDescription(CalculatedStatus status) {
Long lastUpTime = stateLastGood.get();
Long lastDownTime = stateLastGood.get();
Duration serviceFailedStabilizationDelay = getFailedStabilizationDelay();
Duration serviceRecoveredStabilizationDelay = getRecoveredStabilizationDelay();
return String.format("%s; healthy=%s; timeNow=%s; lastUp=%s; lastDown=%s; lastPublished=%s; "+
"currentFailurePeriod=%s; currentRecoveryPeriod=%s",
status.getDescription(),
status.isHealthy(),
Time.makeDateString(System.currentTimeMillis()),
(lastUpTime != null ? Time.makeDateString(lastUpTime) : "<never>"),
(lastDownTime != null ? Time.makeDateString(lastDownTime) : "<never>"),
lastPublished,
(currentFailureStartTime != null ? getTimeStringSince(currentFailureStartTime) : "<none>") + " (stabilization "+makeTimeStringRounded(serviceFailedStabilizationDelay) + ")",
(currentRecoveryStartTime != null ? getTimeStringSince(currentRecoveryStartTime) : "<none>") + " (stabilization "+makeTimeStringRounded(serviceRecoveredStabilizationDelay) + ")");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void assertApplicationEvent(ApplicationEvent event, Lifecycle expectedState, long preEvent, long postEvent) {
// Saw times differ by 1ms - perhaps different threads calling currentTimeMillis() can get out-of-order times?!
final int TIMING_GRACE = 5;
assertEquals(event.getState(), expectedState);
long eventTime = event.getDate().getTime();
if (eventTime < (preEvent - TIMING_GRACE) || eventTime > (postEvent + TIMING_GRACE)) {
fail("for "+expectedState+": event=" + Time.makeDateString(eventTime) + "("+eventTime + "); "
+ "pre=" + Time.makeDateString(preEvent) + " ("+preEvent+ "); "
+ "post=" + Time.makeDateString(postEvent) + " ("+postEvent + ")");
}
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testMakeDateString() {
String in1 = "2015-06-15T12:34:56";
Date d1 = Time.parseDate(in1);
Assert.assertEquals(Time.makeDateString(d1), in1.replace('T', ' ')+".000");
String in2 = "2015-06-15T12:34:56Z";
Date d2 = Time.parseDate(in2);
Assert.assertEquals(Time.makeDateString(d2, Time.DATE_FORMAT_ISO8601, Time.getTimeZone("UTC")), in1+".000+0000");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void assertLocationEvent(LocationEvent event, String expectedAppId, String expectedEntityId, String expectedEntityType, Lifecycle expectedState, long preEvent, long postEvent) {
// Saw times differ by 1ms - perhaps different threads calling currentTimeMillis() can get out-of-order times?!
final int TIMING_GRACE = 5;
assertEquals(event.getApplicationId(), expectedAppId);
assertEquals(event.getEntityId(), expectedEntityId);
assertEquals(event.getEntityType(), expectedEntityType);
assertEquals(event.getState(), expectedState);
long eventTime = event.getDate().getTime();
if (eventTime < (preEvent - TIMING_GRACE) || eventTime > (postEvent + TIMING_GRACE)) {
fail("for "+expectedState+": event=" + Time.makeDateString(eventTime) + "("+eventTime + "); "
+ "pre=" + Time.makeDateString(preEvent) + " ("+preEvent+ "); "
+ "post=" + Time.makeDateString(postEvent) + " ("+postEvent + ")");
}
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void assertLocationEvent(LocationEvent event, String expectedAppId, String expectedEntityId, String expectedEntityType, Lifecycle expectedState, long preEvent, long postEvent) {
// Saw times differ by 1ms - perhaps different threads calling currentTimeMillis() can get out-of-order times?!
final int TIMING_GRACE = 5;
assertEquals(event.getApplicationId(), expectedAppId);
assertEquals(event.getEntityId(), expectedEntityId);
assertEquals(event.getEntityType(), expectedEntityType);
assertEquals(event.getState(), expectedState);
long eventTime = event.getDate().getTime();
if (eventTime < (preEvent - TIMING_GRACE) || eventTime > (postEvent + TIMING_GRACE)) {
fail("for "+expectedState+": event=" + Time.makeDateString(eventTime) + "("+eventTime + "); "
+ "pre=" + Time.makeDateString(preEvent) + " ("+preEvent+ "); "
+ "post=" + Time.makeDateString(postEvent) + " ("+postEvent + ")");
}
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
protected synchronized void onRequesting() {
if (!owningTasks.isEmpty() || !requestingTasks.isEmpty()) {
Tasks.setBlockingTask( !requestingTasks.isEmpty() ? Iterables.getLast(requestingTasks) : Iterables.getFirst(owningTasks, null) );
Tasks.setBlockingDetails("Waiting on semaphore "+getName()+" ("+getDescription()+"); "
+ "queued at "+Time.makeDateString()+" when "+getRequestingThreads().size()+" ahead in queue");
}
requestingTasks.addIfNotNull(Tasks.current());
super.onRequesting();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
private void persist(ManagementNodeSyncRecord node) {
StoreObjectAccessorWithLock writer = getOrCreateNodeWriter(node.getNodeId());
boolean fileExists = writer.exists();
writer.put(serializer.toString(node));
try {
writer.waitForCurrentWrites(SYNC_WRITE_TIMEOUT);
} catch (Exception e) {
throw Exceptions.propagate(e);
}
if (!fileExists) {
changeLogWriter.append(Time.makeDateString()+": created node "+node.getNodeId()+"\n");
}
if (node.getStatus() == ManagementNodeState.TERMINATED || node.getStatus() == ManagementNodeState.FAILED) {
changeLogWriter.append(Time.makeDateString()+": set node "+node.getNodeId()+" status to "+node.getStatus()+"\n");
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-policy
protected String getExplanation(Maybe<Lifecycle> state) {
Duration serviceFailedStabilizationDelay = getConfig(ENTITY_FAILED_STABILIZATION_DELAY);
Duration serviceRecoveredStabilizationDelay = getConfig(ENTITY_RECOVERED_STABILIZATION_DELAY);
return String.format("location=%s; status=%s; lastPublished=%s; timeNow=%s; "+
"currentFailurePeriod=%s; currentRecoveryPeriod=%s",
entity.getLocations(),
(state.orNull() != null ? state : "<unreported>"),
config().get(LAST_PUBLISHED),
Time.makeDateString(System.currentTimeMillis()),
(currentFailureStartTime != null ? getTimeStringSince(currentFailureStartTime) : "<none>") + " (stabilization "+Time.makeTimeStringRounded(serviceFailedStabilizationDelay) + ")",
(currentRecoveryStartTime != null ? getTimeStringSince(currentRecoveryStartTime) : "<none>") + " (stabilization "+Time.makeTimeStringRounded(serviceRecoveredStabilizationDelay) + ")");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/** Method to facilitate creation of memento files */
private void createMemento() throws Exception {
setUp();
origApp = super.createApp();
// edit this, run this class's main method, then use the log output for your test case
origApp.config().set(TEST_KEY, new VersionedName("foo", Version.parseVersion("1.0.0.foo")));
RebindTestUtils.stopPersistence(origApp);
String fn = mementoDir + File.separator + "entities" + File.separator + origApp.getApplicationId();
log.info("Persisted to "+fn);
String yyyyMM = Time.makeDateString(new Date(), "yyyy-MM");
log.info("Set up your tests by copying from the persistence dir "+mementoDir+"\n\n"+
"cp "+fn+" "+
"src/test/resources/"+getClass().getPackage().getName().replaceAll("\\.", "/")+"/"+
JavaClassNames.cleanSimpleClassName(this)+"-"+yyyyMM+"-entity-"+origApp.getApplicationId()+".memento\n");
String content = Streams.readFullyString(new FileInputStream(new File(fn)));
log.info("Or paste the following contents there:\n"+content);
log.info("Then add the apache comment header there, and write your test doing loadEntityMemento(\""+yyyyMM+"\", \""+origApp.getApplicationId()+"\")");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/** as {@link AbstractEntity#initEnrichers()} but also adding default service not-up and problem indicators from children */
@Override
protected void initEnrichers() {
super.initEnrichers();
// default app logic; easily overridable by adding a different enricher with the same tag
ServiceStateLogic.newEnricherFromChildren().checkChildrenAndMembers()
.configure(ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers.UP_QUORUM_CHECK, config().get(UP_QUORUM_CHECK))
.configure(ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers.RUNNING_QUORUM_CHECK, config().get(RUNNING_QUORUM_CHECK))
.addTo(this);
ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application created but not yet started, at "+Time.makeDateString());
}
内容来源于网络,如有侵权,请联系作者删除!