# Issue on Sugar.DateTime

**URL:** https://talk.remobjects.com/t/issue-on-sugar-datetime/6365
**Category:** Silver
**Created:** [June 12, 2015, 3:41am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365 "2015-06-12T03:41:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![saitat](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@saitat](https://talk.remobjects.com/u/saitat)
#### Post date: [June 12, 2015, 3:41am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/1 "2015-06-12T03:41:24Z")

</div>

I’ve created a simply cross-platform static library by C# element on [VS.NET](http://VS.NET) 2015 RC version, the library build successfully and return three different types of static library(.a, .jar and .dll) on corresponding project folders.

I tried to import the .a & .h library into my Xcode Swift 1.2 project ,.jar into my Android studio project and .dll into my [VS.Net](http://VS.Net) 2015 project.

It is working fine on [VS.Net](http://VS.Net) 2015 project, but I got an error on Xcode and Android Studio projects due to the DateTime datatype cannot be reconciled, I think the problem is Java is using “Date” and Xcode is using “NSDate” as the data type

Below is my testing function using c# element VS 2015 RC version

```
public Sugar.DateTime returnDateTime() {
    Sugar.DateTime dummy = Sugar.DateTime.Now;
    
    return dummy;
}

```

Below is the open souroce for Sugar on GitHub, I guess the problem may be related to the following code doesn’t handle the mapping datetime for different platform. please help, thanks.

DateTime = public {$IF COOPER}record{$ELSEIF ECHOES}record mapped to System.DateTime{$ELSEIF NOUGAT}class{$ENDIF}

> <https://github.com/remobjects/sugar/blob/master/Sugar/DateTime.pas>

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [June 13, 2015, 9:22am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/2 "2015-06-13T09:22:55Z")

</div>

> [@saitat](#):
>
> It is working fine on [VS.Net](http://VS.Net) 2015 project, but I got an error on Xcode and Android Studio projects due to the DateTime datatype cannot be reconciled, I think the problem is Java is using “Date” and Xcode is using “NSDate” as the data type

Just to be clear, what error do you get and where do you get it?

---

<div class="post-metadata">

### Author: ![saitat](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@saitat](https://talk.remobjects.com/u/saitat)
#### Post date: [June 15, 2015, 3:20am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/3 "2015-06-15T03:20:37Z")

</div>

[DateTimeTesting.zip](https://talk.remobjects.com/uploads/default/original/2X/1/18edbcc0accc05f9ba955188055a7b19fe87c308.zip) (22.4 KB)

Attached is my testing program.

I got the following error message on Xcode when including the static library, the static library is generated by RemObjects C# under [VS.NET](http://VS.NET) 2015.

"error: unknown type name ‘DateTime’

Or you may find the library from my testing project under the following path:  
../DateTimeTesting\bin\Debug\iOS\libDateTimeTesting.a  
../DateTimeTesting\bin\Debug\iOS\DateTimeTesting.h

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [June 15, 2015, 7:03am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/4 "2015-06-15T07:03:28Z")

</div>

Thanks, logged as bugs://72264

---

<div class="post-metadata">

### Author: ![saitat](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@saitat](https://talk.remobjects.com/u/saitat)
#### Post date: [June 15, 2015, 8:21am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/5 "2015-06-15T08:21:08Z")

</div>

May I know your timeline for the next release? thanks. 😀

---

<div class="post-metadata">

### Author: ![viktoriad](https://talk.remobjects.com/user_avatar/talk.remobjects.com/viktoriad/32/11148_2.png) [@viktoriad](https://talk.remobjects.com/u/viktoriad)
#### Post date: [June 17, 2015, 12:01pm UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/6 "2015-06-17T12:01:47Z")

</div>

Hello,

Could you please give me more info on that error. I tried to reproduce it for Android Studio and couldn’t. With referenced .jar I’m able to call the returnDateTime method and the project compiles fine. Though I added reference to sugar to be able to assign the result of method to any var.  
Did you added the reference to sugar also (sugar.jar for Android).

Best regards.

---

<div class="post-metadata">

### Author: ![saitat](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@saitat](https://talk.remobjects.com/u/saitat)
#### Post date: [June 18, 2015, 6:02am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/7 "2015-06-18T06:02:07Z")

</div>

Which method I need to use for my Android Studio project in order to get the result from returnDateTime function?

**Method 1**  
Sugar.DateTime a = returnDateTime ();

or

**Method 2**  
Date a = returnDateTime ();

Currently I’m using method 2 in my JAVA project.

---

<div class="post-metadata">

### Author: ![viktoriad](https://talk.remobjects.com/user_avatar/talk.remobjects.com/viktoriad/32/11148_2.png) [@viktoriad](https://talk.remobjects.com/u/viktoriad)
#### Post date: [June 18, 2015, 8:10am UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/8 "2015-06-18T08:10:22Z")

</div>

Hello,

we have added the changes into sugar. Now the DateTime type is mapped to java.util.Calendar for java and NSDate for nougat.

Best regards.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [June 18, 2015, 12:00pm UTC](https://talk.remobjects.com/t/issue-on-sugar-datetime/6365/9 "2015-06-18T12:00:03Z")

</div>

bugs://72264 got closed with status fixed.
