當前位置: 首頁>>代碼示例>>Java>>正文


Java OffsetTime.parse方法代碼示例

本文整理匯總了Java中java.time.OffsetTime.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java OffsetTime.parse方法的具體用法?Java OffsetTime.parse怎麽用?Java OffsetTime.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.OffsetTime的用法示例。


在下文中一共展示了OffsetTime.parse方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertDateInternal

import java.time.OffsetTime; //導入方法依賴的package包/類
static <T> T convertDateInternal(String string, Class<T> type, ZoneId fallbackZoneId) {
   if (java.util.Date.class.equals(type)) {
      return (T) java.util.Date.from(parseInstant(string, fallbackZoneId));
   } else if (java.sql.Date.class.equals(type)) {
      return (T) java.sql.Date.from(parseInstant(string, fallbackZoneId));
   } else if (Time.class.equals(type)) {
      return (T) Time.from(parseInstant(string, fallbackZoneId));
   } else if (Timestamp.class.equals(type)) {
      return (T) Timestamp.from(parseInstant(string, fallbackZoneId));
   } else if (LocalTime.class.equals(type)) {
      return (T) LocalTime.parse(string);
   } else if (LocalDate.class.equals(type)) {
      return (T) LocalDate.parse(string);
   } else if (LocalDateTime.class.equals(type)) {
      return (T) LocalDateTime.parse(string);
   } else if (ZonedDateTime.class.equals(type)) {
      return (T) ZonedDateTime.parse(string);
   } else if (OffsetDateTime.class.equals(type)) {
      return (T) OffsetDateTime.parse(string);
   } else if (OffsetTime.class.equals(type)) {
      return (T) OffsetTime.parse(string);
   }

   return null;
}
 
開發者ID:btc-ag,項目名稱:redg,代碼行數:26,代碼來源:DateConverter.java

示例2: parse

import java.time.OffsetTime; //導入方法依賴的package包/類
@Override
public TemporalAccessor parse(String text, Locale locale) throws ParseException {
	DateTimeFormatter formatterToUse = DateTimeContextHolder.getFormatter(this.formatter, locale);
	if (LocalDate.class.equals(this.temporalAccessorType)) {
		return LocalDate.parse(text, formatterToUse);
	}
	else if (LocalTime.class.equals(this.temporalAccessorType)) {
		return LocalTime.parse(text, formatterToUse);
	}
	else if (LocalDateTime.class.equals(this.temporalAccessorType)) {
		return LocalDateTime.parse(text, formatterToUse);
	}
	else if (ZonedDateTime.class.equals(this.temporalAccessorType)) {
		return ZonedDateTime.parse(text, formatterToUse);
	}
	else if (OffsetDateTime.class.equals(this.temporalAccessorType)) {
		return OffsetDateTime.parse(text, formatterToUse);
	}
	else if (OffsetTime.class.equals(this.temporalAccessorType)) {
		return OffsetTime.parse(text, formatterToUse);
	}
	else {
		throw new IllegalStateException("Unsupported TemporalAccessor type: " + this.temporalAccessorType);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:TemporalAccessorParser.java

示例3: decode

import java.time.OffsetTime; //導入方法依賴的package包/類
@Override
public OffsetTime decode(
        BsonReader reader,
        DecoderContext decoderContext) {

    return OffsetTime.parse(reader.readString());
}
 
開發者ID:cbartosiak,項目名稱:bson-codecs-jsr310,代碼行數:8,代碼來源:OffsetTimeCodec.java

示例4: deserialze

import java.time.OffsetTime; //導入方法依賴的package包/類
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 4) {
        String text = lexer.stringVal();
        lexer.nextToken();
        if (type == LocalDateTime.class) {
            return LocalDateTime.parse(text);
        }
        if (type == LocalDate.class) {
            return LocalDate.parse(text);
        }
        if (type == LocalTime.class) {
            return LocalTime.parse(text);
        }
        if (type == ZonedDateTime.class) {
            return ZonedDateTime.parse(text);
        }
        if (type == OffsetDateTime.class) {
            return OffsetDateTime.parse(text);
        }
        if (type == OffsetTime.class) {
            return OffsetTime.parse(text);
        }
        if (type == ZoneId.class) {
            return ZoneId.of(text);
        }
        if (type == Period.class) {
            return Period.parse(text);
        }
        if (type == Duration.class) {
            return Duration.parse(text);
        }
        if (type == Instant.class) {
            return Instant.parse(text);
        }
        return null;
    }
    throw new UnsupportedOperationException();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:40,代碼來源:Jdk8DateCodec.java

示例5: factory_parse_formatter_nullFormatter

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
    OffsetTime.parse("ANY", null);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:TCKOffsetTime.java

示例6: factory_parse_validText

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(dataProvider = "sampleToString")
public void factory_parse_validText(int h, int m, int s, int n, String offsetId, String parsable) {
    OffsetTime t = OffsetTime.parse(parsable);
    assertNotNull(t, parsable);
    check(t, h, m, s, n, ZoneOffset.of(offsetId));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKOffsetTime.java

示例7: factory_parse_invalidText

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class})
public void factory_parse_invalidText(String unparsable) {
    OffsetTime.parse(unparsable);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java

示例8: factory_parse_illegalHour

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions={DateTimeParseException.class})
public void factory_parse_illegalHour() {
    OffsetTime.parse("25:00+01:00");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java

示例9: factory_parse_illegalMinute

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions={DateTimeParseException.class})
public void factory_parse_illegalMinute() {
    OffsetTime.parse("12:60+01:00");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java

示例10: factory_parse_illegalSecond

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions={DateTimeParseException.class})
public void factory_parse_illegalSecond() {
    OffsetTime.parse("12:12:60+01:00");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKOffsetTime.java

示例11: factory_parse_formatter

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s XXX");
    OffsetTime test = OffsetTime.parse("11 30 0 +01:00", f);
    assertEquals(test, OffsetTime.of(11, 30, 0, 0, ZoneOffset.ofHours(1)));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKOffsetTime.java

示例12: factory_parse_formatter_nullText

import java.time.OffsetTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
    OffsetTime.parse((String) null, f);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKOffsetTime.java

示例13: decodeText

import java.time.OffsetTime; //導入方法依賴的package包/類
@Override
public OffsetTime decodeText(int len, ByteBuf buff) {
  CharSequence cs = buff.readCharSequence(len, StandardCharsets.UTF_8);
  return OffsetTime.parse(cs, TIMETZ_FORMAT);
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:6,代碼來源:DataType.java


注:本文中的java.time.OffsetTime.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。