2

I'm trying to use DateTime for the first time.

I'm working with Java on IntelliJ.

I've tried writing:

DateTime dt = new DateTime();

but I get a "Cannot resolve symbol DateTime" error.

What should I do?

S.L. Barth
  • 8,058
  • 71
  • 49
  • 63
Dina Kleper
  • 1,675
  • 3
  • 15
  • 21

1 Answers1

5

You should import this class, add the following line in the beginning:

import org.joda.time.DateTime;

Note also that JodaTime library should be somehow available to your code, either manually connected as a jar or linked through Maven or other dependency management tool.

Scadge
  • 8,963
  • 3
  • 28
  • 38
  • Thank you! would you also mind telling me how to connet the JodaTime library? – Dina Kleper Nov 17 '15 at 07:46
  • 1
    First download the archive from https://github.com/JodaOrg/joda-time/releases and you'll get the joda-time-2.9.jar inside. After that, depending on your IDE, add this jar to your project. Example for Eclipse: http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse – Scadge Nov 17 '15 at 07:54