#Java - Code Snippets for '#Java.util.date' - 4 code snippet(s) found |
|
Sample 1. Initialize java.util.date using java.util.Calendar | |
|
Date currentDate = Calendar.getInstance().getTime();
|
|
Like Feedback calendar java.util.calendar java.util date java.util.date Calendar.getTime |
|
|
Sample 2. Time Taken to call a method or service | |
|
Date date1 = new Date();
// Call Service or Method
Date date2 = new Date();
System.out.println(TimeUnit.SECONDS.convert(date2.getTime()-date1.getTime(), TimeUnit.MILLISECONDS));// Time Taken in Seconds
System.out.println(TimeUnit.MINUTES.convert(date2.getTime()-date1.getTime(), TimeUnit.MILLISECONDS));// Time Taken in Minutes
System.out.println(TimeUnit.HOURS.convert(date2.getTime()-date1.getTime(), TimeUnit.MILLISECONDS));// Time Taken in Hours
|
|
Like Feedback Difference between 2 dates Time to call a method TimeUnit Date.java.util.Date |
|
|
Sample 3. Usage of org.apache.abdera.model.Entry; | |
|
Entry entry = factory.newEntry();
entry.setId(FOMHelper.generateUuid());
entry.setUpdated(new java.util.Date());
entry.addAuthor("James");
entry.setTitle("Posting to Roller");
entry.setContentAsHtml("<p>This is an example post to Roller</p>");
AbderaClient abderaClient = new AbderaClient(abdera);
abderaClient.addCredentials(start, null, null, new UsernamePasswordCredentials("username", "password"));
Document<Service> service_doc = abderaClient.get(start).getDocument();
Service service = service_doc.getRoot();
Collection collection = service.getWorkspaces().get(0).getCollections().get(0);
String uri = collection.getHref().toString();
Response response = abderaClient.post(uri, entry);
|
|
Like Feedback |
|
|
Sample 4. Usage of org.joda.time.DateMidnight | |
|
DateMidnight currentDate = new DateMidnight();
DateMidnight dateafterAMonth = currentDate.plusMonths(1);
Date javaSedateAfterAMonth = dateafterAMonth.toDate();
|
|
Like Feedback org.joda.time.DateMidnight java.util.Date Date Add month to Date |
|
|