org.threeten.bp.OffsetDateTime Java Examples

The following examples show how to use org.threeten.bp.OffsetDateTime. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 
 *
 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 
 *
 * @throws IOException
 *          if the Api call fails
 */
@Test
public void testEndpointParametersTest() throws IOException {
    BigDecimal number = null;
    Double _double = null;
    String patternWithoutDelimiter = null;
    byte[] _byte = null;
    Integer integer = null;
    Integer int32 = null;
    Long int64 = null;
    Float _float = null;
    String string = null;
    File binary = null;
    LocalDate date = null;
    OffsetDateTime dateTime = null;
    String password = null;
    String paramCallback = null;
    api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);

    // TODO: test validations
}
 
Example #2
Source File: FormatTest.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
FormatTest(Parcel in) {
  integer = (Integer)in.readValue(null);
  int32 = (Integer)in.readValue(null);
  int64 = (Long)in.readValue(null);
  number = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
  _float = (Float)in.readValue(null);
  _double = (Double)in.readValue(null);
  string = (String)in.readValue(null);
  _byte = (byte[])in.readValue(null);
  binary = (File)in.readValue(File.class.getClassLoader());
  date = (LocalDate)in.readValue(LocalDate.class.getClassLoader());
  dateTime = (OffsetDateTime)in.readValue(OffsetDateTime.class.getClassLoader());
  uuid = (UUID)in.readValue(UUID.class.getClassLoader());
  password = (String)in.readValue(null);
  bigDecimal = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader());
}
 
Example #3
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
public HttpResponse testEndpointParametersForHttpResponse(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, File binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws IOException {
    // verify the required parameter 'number' is set
    if (number == null) {
        throw new IllegalArgumentException("Missing the required parameter 'number' when calling testEndpointParameters");
    }// verify the required parameter '_double' is set
    if (_double == null) {
        throw new IllegalArgumentException("Missing the required parameter '_double' when calling testEndpointParameters");
    }// verify the required parameter 'patternWithoutDelimiter' is set
    if (patternWithoutDelimiter == null) {
        throw new IllegalArgumentException("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters");
    }// verify the required parameter '_byte' is set
    if (_byte == null) {
        throw new IllegalArgumentException("Missing the required parameter '_byte' when calling testEndpointParameters");
    }
    UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake");

    String localVarUrl = uriBuilder.build().toString();
    GenericUrl genericUrl = new GenericUrl(localVarUrl);

    HttpContent content = new EmptyContent();
    return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute();
}
 
Example #4
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 
 *
 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 
 */
@Test
public void testEndpointParametersTest() {
    BigDecimal number = null;
    Double _double = null;
    String patternWithoutDelimiter = null;
    byte[] _byte = null;
    Integer integer = null;
    Integer int32 = null;
    Long int64 = null;
    Float _float = null;
    String string = null;
    File binary = null;
    LocalDate date = null;
    OffsetDateTime dateTime = null;
    String password = null;
    String paramCallback = null;
    // api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);

    // TODO: test validations
}
 
Example #5
Source File: FakeApiTest.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
/**
 * Invalid username supplied
 */
@Test
public void shouldSee400AfterTestEndpointParameters() {
    BigDecimal number = null;
    Double _double = null;
    String patternWithoutDelimiter = null;
    byte[] _byte = null;
    Integer integer = null;
    Integer int32 = null;
    Long int64 = null;
    Float _float = null;
    String string = null;
    File binary = null;
    LocalDate date = null;
    OffsetDateTime dateTime = null;
    String password = null;
    String paramCallback = null;
    api.testEndpointParameters()
            .numberForm(number)
            ._doubleForm(_double)
            .patternWithoutDelimiterForm(patternWithoutDelimiter)
            ._byteForm(_byte).execute(r -> r.prettyPeek());
    // TODO: test validations
}
 
Example #6
Source File: MixedPropertiesAndAdditionalPropertiesClass.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get dateTime
 * @return dateTime
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")

public OffsetDateTime getDateTime() {
  return dateTime;
}
 
Example #7
Source File: TimesheetLine.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #8
Source File: FormatUtils.java    From JReadHub with GNU General Public License v3.0 5 votes vote down vote up
public static OffsetDateTime string2ODT(String timeStr) {
    if (!TextUtils.isEmpty(timeStr)) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        LocalDateTime localDateTime = LocalDateTime.parse(timeStr, df);
        return OffsetDateTime.of(localDateTime, ZoneOffset.UTC);
    }
    return null;
}
 
Example #9
Source File: Receipt.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #10
Source File: ReimbursementType.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #11
Source File: JSON.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
public JSON() {
    gson = createGson()
        .registerTypeAdapter(Date.class, dateTypeAdapter)
        .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
        .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
        .registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
        .registerTypeAdapter(byte[].class, byteArrayAdapter)
        .create();
}
 
Example #12
Source File: JSONTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Test
public void testOffsetDateTimeTypeAdapter() {
    final String str = "\"2016-09-09T08:02:03.123-03:00\"";
    OffsetDateTime date = OffsetDateTime.of(2016, 9, 9, 8, 2, 3, 123000000, ZoneOffset.of("-3"));

    assertEquals(str, json.serialize(date));
    //Use toString() instead of isEqual to verify that the offset is preserved
    assertEquals(json.deserialize(str, OffsetDateTime.class).toString(), date.toString());
}
 
Example #13
Source File: BatchPayment.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #14
Source File: HistoryRecord.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getDateUTCAsDate() {
  if (this.dateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.dateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #15
Source File: MixedPropertiesAndAdditionalPropertiesClass.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get dateTime
 * @return dateTime
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_DATE_TIME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public OffsetDateTime getDateTime() {
  return dateTime;
}
 
Example #16
Source File: LeaveType.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #17
Source File: JSON.java    From huaweicloud-cs-sdk with Apache License 2.0 5 votes vote down vote up
public JSON() {
    gson = createGson()
        .registerTypeAdapter(Date.class, dateTypeAdapter)
        .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
        .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
        .registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
        .create();
}
 
Example #18
Source File: HistoryStat.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
public HistoryStat(int days){
        lastDays = days;
        startOfToday = LocalDate.now().atStartOfDay().toInstant(OffsetDateTime.now().getOffset()).toEpochMilli();
        startOfThisMonth = LocalDate.now().withDayOfMonth(1).atStartOfDay()
                .toInstant(OffsetDateTime.now().getOffset()).toEpochMilli();
        startOfLastDays = LocalDate.now().minusDays(days - 1).atStartOfDay()
                .toInstant(OffsetDateTime.now().getOffset()).toEpochMilli();
//        dataOfLastDays = DataSupport.where("timestamp > ?", Long.toString(startOfLastDays))
//                .find(History.class);
        dataOfLastDays = ExternalDatabase.getInstance().getHistoryAfter(startOfLastDays);
    }
 
Example #19
Source File: EarningsRate.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #20
Source File: Order.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get shipDate
 * @return shipDate
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")

public OffsetDateTime getShipDate() {
  return shipDate;
}
 
Example #21
Source File: JSON.java    From nifi-swagger-client with Apache License 2.0 5 votes vote down vote up
@Override
public OffsetDateTime read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            if (date.endsWith("+0000")) {
                date = date.substring(0, date.length()-5) + "Z";
            }
            return OffsetDateTime.parse(date, formatter);
    }
}
 
Example #22
Source File: OffsetDateTimeConverterTest.java    From ThreeTen-Backport-Gson-Adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeserialization() {
    String json = "\"2010-08-20T10:37:50+08:00\"";

    OffsetDateTime offsetDateTime = gson.fromJson(json, OffsetDateTime.class);

    assertEquals(offsetDateTime, OffsetDateTime.parse("2010-08-20T10:37:50+08:00"));
}
 
Example #23
Source File: Account.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #24
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
public JSON() {
    gson = createGson()
        .registerTypeAdapter(Date.class, dateTypeAdapter)
        .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
        .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
        .registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
        .registerTypeAdapter(byte[].class, byteArrayAdapter)
        .create();
}
 
Example #25
Source File: FormatTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get dateTime
 * @return dateTime
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")

public OffsetDateTime getDateTime() {
  return dateTime;
}
 
Example #26
Source File: JSON.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
@Override
public void write(JsonWriter out, OffsetDateTime date) throws IOException {
    if (date == null) {
        out.nullValue();
    } else {
        out.value(formatter.format(date));
    }
}
 
Example #27
Source File: JacksonConfiguration.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ThreeTenModule.class)
ThreeTenModule threeTenModule() {
  ThreeTenModule module = new ThreeTenModule();
  module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
  module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
  module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
  return module;
}
 
Example #28
Source File: BankTransaction.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}
 
Example #29
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public OffsetDateTime read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            if (date.endsWith("+0000")) {
                date = date.substring(0, date.length()-5) + "Z";
            }
            return OffsetDateTime.parse(date, formatter);
    }
}
 
Example #30
Source File: PayrollCalendar.java    From Xero-Java with MIT License 5 votes vote down vote up
public OffsetDateTime getUpdatedDateUTCAsDate() {
  if (this.updatedDateUTC != null) {
    try {
      return util.convertStringToOffsetDateTime(this.updatedDateUTC);
    } catch (IOException e) {
      e.printStackTrace();
    }  
  }
  return null;        
}