Date api code example

Example 1: javascript date

const d = new Date();
d.getFullYear(); // 2020
d.getMonth(); // October
d.getDate(); // 4
d.getHours(); // 11
d.getMinutes(); // 20
d.getSeconds(); // 12
d.getMilliseconds(); // 0
d.getTime(); // ????????????

Example 2: dates in java 8

LocalDateTime.parse("2015-02-20T06:30:00");

Example 3: What is API response time?

Response time is the amount of time
 a system takes to react to a request
 when they received one.
Basically this is Remote Response time.

 
If file not under resources: 
File schemaFile = new File("src/test/resources/postSuccessResponseSchema.json");

     given()
        .spec(adminReqSpec)
        .contentType(ContentType.JSON)
        .body(abcUtil.getRandomHeroPOJO_Payload()).
     when()
        .post("/HEROS").
     then()
        .body(matchesJsonSchema( schemaFile )  ) 
        
        
If schema file under resources:
  given()
      .spec(adminReqSpec)
      .queryParam("nameContains","a")
      .queryParam("gender","Female").
  when()
      .get("/abc/search").
 then()
 	  .time( lessThan(2000L));	
      .body(matchesJsonSchemaInClasspath("searchSpartanSchema.json") )

Example 4: dates in java 8

LocalTime sixThirty = LocalTime.parse("06:30");

Tags:

Java Example