Author Message
Andrew.Prokop
Joined: Oct 28, 2014
Messages: 179
Offline
Again, forgive my ignorance...

I want to use the Java class Instant to determine the current date and time. I added the following to my code:

import java.time.Instant;
.
.
.
Instant.now().toString();

It builds just fine, but I get an class not found error during execution.

I understand that I need to add a dependency in pom.xml, but I don't know what it is I need to add. I am unfamiliar with the format.

What is the formula for adding such things?

Thanks!
PrakashN
Joined: Jun 30, 2015
Messages: 105
Offline
Andrew,

I am assuming you are adding this to your task code.

java.time.Instant is introduced starting from only Java 8. We are still on Java 7. Please use java.util.Calendar and something like
Calendar.getInstance().getTime() to get the current time in your task.

I hope this helps...

Prakash Natarajan System Architecture Consulting Engineer Engagement Designer Avaya
Andrew.Prokop
Joined: Oct 28, 2014
Messages: 179
Offline
Yes, adding to my task code. I will look at your suggestion. Instant gave me the data is the format I required. That's why I started with it.

A broader question is how to I determine how to add new dependencies? I followed someone elses code to add the following for http, but I honestly don't know how it was determined that this was the right stuff to add.

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
PrakashN
Joined: Jun 30, 2015
Messages: 105
Offline
You are doing the right thing by adding additional dependencies to your pom.xml. The group id, artifact id and version information come from the jars you are adding. The scope is added to determine how you want to add the jars to the project. If you add a "compile" scope, it adds those jars to your final package and hence your jar size gets bloated up. If you add a "provided" scope, it does not add the hars to your package, but expects the classes to be present at runtime.

What scope you choose depends on what and how do you want to add your dependencies.

Prakash Natarajan System Architecture Consulting Engineer Engagement Designer Avaya
Go to:   
Mobile view