List of usage examples for java.util Date from
public static Date from(Instant instant)
From source file:org.sakaiproject.assignment.persistence.AssignmentRepositoryImpl.java
@Override @Transactional// w ww . ja va 2 s.c om public void newAssignment(Assignment assignment) { if (!existsAssignment(assignment.getId())) { assignment.setDateCreated(Date.from(Instant.now())); sessionFactory.getCurrentSession().persist(assignment); } }
From source file:com.vmware.photon.controller.api.client.resource.ImagesApiTest.java
@Test public void testUploadImage() throws IOException { File temp = File.createTempFile("temp-image", ".vmdk"); (new File(temp.getAbsolutePath())).deleteOnExit(); Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); ImagesApi imagesApi = new ImagesApi(this.restClient); Task task = imagesApi.uploadImage(temp.getAbsolutePath()); assertEquals(task, responseTask);/*from w w w. ja va2 s . c om*/ }
From source file:com.vmware.photon.controller.api.client.resource.ImagesRestApiTest.java
@Test public void testUploadImage() throws IOException { File temp = File.createTempFile("temp-image", ".vmdk"); (new File(temp.getAbsolutePath())).deleteOnExit(); Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); ImagesApi imagesApi = new ImagesRestApi(this.restClient); Task task = imagesApi.uploadImage(temp.getAbsolutePath()); assertEquals(task, responseTask);//from w ww .j a va 2 s. co m }
From source file:oauth2.authentication.approvals.ApprovalServiceImpl.java
private static Date toDate(Instant instant) { if (instant == null) { return null; }//from w w w . ja va2 s . co m return Date.from(instant); }
From source file:com.vmware.photon.controller.api.client.resource.TasksApiTest.java
@Test public void testGetTaskAsync() throws Throwable { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksApi(this.restClient); tasksApi.getTaskAsync("foo", new FutureCallback<Task>() { @Override/* www . j a va2 s . co m*/ public void onSuccess(@Nullable Task task) { assertEquals(task, responseTask); } @Override public void onFailure(Throwable t) { fail(t.toString()); } }); }
From source file:com.vmware.photon.controller.api.client.resource.TasksRestApiTest.java
@Test public void testGetTaskAsync() throws Throwable { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksRestApi(this.restClient); tasksApi.getTaskAsync("foo", new FutureCallback<Task>() { @Override/* w w w . j a v a 2 s . c o m*/ public void onSuccess(@Nullable Task task) { assertEquals(task, responseTask); } @Override public void onFailure(Throwable t) { fail(t.toString()); } }); }
From source file:com.onyxscheduler.domain.Trigger.java
public org.quartz.Trigger buildQuartzTrigger() { if (cron != null) { return TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(cron)).build(); } else {/*from w w w . j av a 2s. c o m*/ return TriggerBuilder.newTrigger().startAt(Date.from(when)).build(); } }
From source file:eu.openg.aws.s3.internal.FakeS3Object.java
private void updateContentMetadata(byte[] content) { ObjectMetadata metadata = object.getObjectMetadata(); setMd5(computeMD5Hash(content));//from w w w.j a va 2 s. c om metadata.setContentType("text/plain"); metadata.setContentLength(content.length); metadata.setLastModified(Date.from(clock.instant())); }
From source file:com.vmware.photon.controller.api.client.resource.FlavorApiTest.java
@Test public void testCreate() throws IOException { Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); FlavorApi flavorApi = new FlavorApi(restClient); Task task = flavorApi.create(new FlavorCreateSpec()); assertEquals(task, responseTask);//from w w w. ja v a2 s .c o m }
From source file:com.vmware.photon.controller.api.client.resource.FlavorRestApiTest.java
@Test public void testCreate() throws IOException { Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); FlavorApi flavorApi = new FlavorRestApi(restClient); Task task = flavorApi.create(new FlavorCreateSpec()); assertEquals(task, responseTask);// w w w .j a va2s . c o m }