本文整理了Java中java.time.ZonedDateTime.toString()
方法的一些代码示例,展示了ZonedDateTime.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.toString()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:toString
[英]Outputs this date-time as a String, such as 2007-12-03T10:15:30+01:00[Europe/Paris].
The format consists of the LocalDateTime followed by the ZoneOffset. If the ZoneId is not the same as the offset, then the ID is output. The output is compatible with ISO-8601 if the offset and ID are the same.
[中]以字符串形式输出此日期时间,例如2007-12-03T10:15:30+01:00[欧洲/巴黎]。
格式由LocalDateTime后跟ZoneOffset组成。如果ZoneId与偏移量不同,则输出ID。如果偏移量和ID相同,则输出与ISO-8601兼容。
代码示例来源:origin: spring-projects/spring-loaded
public static String run() {
LocalDateTime time = LocalDateTime.now();
ZonedDateTime zdt = time.atZone(ZoneId.systemDefault());
return zdt.toString();
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public byte[] convert(ZonedDateTime source) {
return fromString(source.toString());
}
}
代码示例来源:origin: google/rejoiner
@SchemaModification(addField = "localTime", onType = Timestamp.class)
String localTime(Timestamp timestamp, @Arg("timezone") String timezone) {
// TODO: Arg should be required, optional should be optional
return Instant.ofEpochSecond(timestamp.getSeconds()).atZone(ZoneId.of(timezone)).toString();
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeDateTime( ZonedDateTime zonedDateTime ) throws RuntimeException
{
append( "{datetime: " );
append( quote( zonedDateTime.toString() ) );
append( "}" );
}
代码示例来源:origin: resilience4j/resilience4j
private static CircuitBreakerEventDTOBuilder newCircuitBreakerEventDTOBuilder(CircuitBreakerEvent event){
return new CircuitBreakerEventDTOBuilder(event.getCircuitBreakerName(), event.getEventType(), event.getCreationTime().toString());
}
}
代码示例来源:origin: resilience4j/resilience4j
private static CircuitBreakerEventDTOBuilder newCircuitBreakerEventDTOBuilder(CircuitBreakerEvent event){
return new CircuitBreakerEventDTOBuilder(event.getCircuitBreakerName(), event.getEventType(), event.getCreationTime().toString());
}
}
代码示例来源:origin: resilience4j/resilience4j
private static CircuitBreakerEventDTOBuilder newCircuitBreakerEventDTOBuilder(CircuitBreakerEvent event){
return new CircuitBreakerEventDTOBuilder(event.getCircuitBreakerName(), event.getEventType(), event.getCreationTime().toString());
}
}
代码示例来源:origin: resilience4j/resilience4j
public static BulkheadEventDTO createEventDTO(BulkheadEvent bulkheadEvent) {
return new BulkheadEventDTO(bulkheadEvent.getBulkheadName(), bulkheadEvent.getEventType(), bulkheadEvent.getCreationTime().toString());
}
代码示例来源:origin: apache/hive
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 0) {
throw new UDFArgumentLengthException(
"The function CURRENT_DATE does not take any arguments, but found "
+ arguments.length);
}
if (currentDate == null) {
SessionState ss = SessionState.get();
ZonedDateTime dateTime = ss.getQueryCurrentTimestamp().atZone(
ss.getConf().getLocalTimeZone());
Date dateVal = Date.valueOf(
dateTime.toString().substring(0, 10));
currentDate = new DateWritableV2(dateVal);
}
return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
}
代码示例来源:origin: resilience4j/resilience4j
public static RateLimiterEventDTO createRateLimiterEventDTO(RateLimiterEvent rateLimiterEvent) {
RateLimiterEventDTO dto = new RateLimiterEventDTO();
dto.setRateLimiterName(rateLimiterEvent.getRateLimiterName());
dto.setRateLimiterEventType(rateLimiterEvent.getEventType());
dto.setRateLimiterCreationTime(rateLimiterEvent.getCreationTime().toString());
return dto;
}
代码示例来源:origin: resilience4j/resilience4j
public static RateLimiterEventDTO createRateLimiterEventDTO(RateLimiterEvent rateLimiterEvent) {
RateLimiterEventDTO dto = new RateLimiterEventDTO();
dto.setRateLimiterName(rateLimiterEvent.getRateLimiterName());
dto.setRateLimiterEventType(rateLimiterEvent.getEventType());
dto.setRateLimiterCreationTime(rateLimiterEvent.getCreationTime().toString());
return dto;
}
代码示例来源:origin: resilience4j/resilience4j
public static RateLimiterEventDTO createRateLimiterEventDTO(RateLimiterEvent rateLimiterEvent) {
RateLimiterEventDTO dto = new RateLimiterEventDTO();
dto.setRateLimiterName(rateLimiterEvent.getRateLimiterName());
dto.setRateLimiterEventType(rateLimiterEvent.getEventType());
dto.setRateLimiterCreationTime(rateLimiterEvent.getCreationTime().toString());
return dto;
}
代码示例来源:origin: resilience4j/resilience4j
public static RetryEventDTO createRetryEventDTO(RetryEvent retryEvent) {
RetryEventDTO dto = new RetryEventDTO();
dto.setRetryName(retryEvent.getName());
dto.setRetryEventType(retryEvent.getEventType());
dto.setNumberOfRetryAttempts(retryEvent.getNumberOfRetryAttempts());
dto.setRetryCreationTime(retryEvent.getCreationTime().toString());
return dto;
}
代码示例来源:origin: stackoverflow.com
LocalDateTime ldt = LocalDateTime.now();
ZonedDateTime zdt = ldt.atZone(ZoneOffset.UTC); //you might use a different zone
String iso8061 = zdt.toString();
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Adds human readable version and creation date settings.
* This method is used to display the settings in a human readable format in REST API
*/
public static Settings addHumanReadableSettings(Settings settings) {
Settings.Builder builder = Settings.builder().put(settings);
Version version = SETTING_INDEX_VERSION_CREATED.get(settings);
if (version != Version.V_EMPTY) {
builder.put(SETTING_VERSION_CREATED_STRING, version.toString());
}
Version versionUpgraded = settings.getAsVersion(SETTING_VERSION_UPGRADED, null);
if (versionUpgraded != null) {
builder.put(SETTING_VERSION_UPGRADED_STRING, versionUpgraded.toString());
}
Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null);
if (creationDate != null) {
ZonedDateTime creationDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(creationDate), ZoneOffset.UTC);
builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString());
}
return builder.build();
}
代码示例来源:origin: palantir/atlasdb
@Override
public int execute(AtlasDbServices services) {
if (epochTime == null) {
throw new IllegalArgumentException("Required option '-e' is missing");
}
if (epochTime < 0) {
throw new IllegalArgumentException("Option '-e' should be a positive long, as epoch time"
+ " is never negative.");
}
Instant epochTimeInstant = Instant.ofEpochSecond(epochTime);
ZonedDateTime date = ZonedDateTime.ofInstant(epochTimeInstant, ZoneId.systemDefault());
printer.info("Input {} in epoch millis is {}",
SafeArg.of("epochMillis", epochTime),
SafeArg.of("date", date.toString()));
KeyValueService keyValueService = services.getKeyValueService();
PuncherStore puncherStore = KeyValueServicePuncherStore.create(keyValueService, false);
Long value = puncherStore.get(epochTime);
printer.info("The first timestamp before {} is {}",
SafeArg.of("date", date.toString()),
SafeArg.of("timestamp", value));
return 0;
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-util-api
@Override
public String convert(final ZonedDateTime zonedDateTime) {
return zonedDateTime.toString();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-mongo-core
@Override
public String convert(final ZonedDateTime source) {
return source == null ? null : source.toString();
}
}
代码示例来源:origin: com.vmware.card-connectors/connectors-common
private String getSurrogateId() {
String fingerprint = getSubject() + ':' + getSender().getEmailAddress() + ':' + getSentDate().toString();
CRC32 checksummer = new CRC32();
checksummer.update(fingerprint.getBytes());
return Long.toHexString(checksummer.getValue());
}
}
代码示例来源:origin: org.apereo.cas/cas-server-core-util-api
/**
* To string.
*
* @return the string
*/
public static String asString() {
return getVersion() + " - " + getSpecificationVersion() + " - " + getDateTime().toString();
}
内容来源于网络,如有侵权,请联系作者删除!