0

I am wondering how I can use two classes with the same name (DateTime) from two different libraries. I am using two libraries, each with the following purpose:

  1. org.joda.time.DateTime: Used to convert a DateTime date from a Gregorian calendar to the Islamic Hijri calendar.
  2. hirondelle.date4j.DateTime: Required in a Calendar library to get the date of a calendar's cell.

However, when I execute the below import statements, I get an error on my import of hirondelle.date4j.DateTime import, stating that org.joda.time.DateTime is already defined in a single-type import.

Adam Lee
  • 436
  • 1
  • 14
  • 49
  • 1
    You have to fully-qualify at least one of them. That is, import `org.joda.time.DateTime` and then refer to the other one in code as `hirondelle.date4j.DateTime` (no import). (Or vice versa; or import neither and fully-qualify both) – Andy Turner Aug 18 '21 at 22:29
  • Why is a Java question tagged as C# and .NET, but not Java? It is not clear what language you are even asking for. – Christopher Aug 18 '21 at 22:36
  • @Christopher Fixed the tags. – Adam Lee Aug 18 '21 at 22:39

1 Answers1

0

@AndyTurner was correct, all I had to do was to fully qualify at least one of the usages of the libraries, like shown below:

hirondelle.date4j.DateTime dateTime = this.datetimeList.get(position);
Adam Lee
  • 436
  • 1
  • 14
  • 49