DATETIME type

Hello!
I have simple problem. Which format should be used for columns with DATETIME type? I clicked on field, then “Now” but in saving i’m getting error: “Invalid date format for property BirthDay”

Hi Michael,

I assume you’re talking about entering a value for DATETIME in console. When you click on a field, console shows date/time picker. Here’s what it looks like.
http://support.backendless.com/public/attachments/bd269865a8c8e556a18d59c8be47bc02.jpg</img>

It sounds like you’re doing something different. Could you describe in more details?

Mark

Hm… I found that this problem I was getting in the RU version backendless.com. In US version values can be saved clearly.

Hello, Michael!

We shall make investigation and fix this issue in the nearest release.

best regards,
Alex Navara

Hello

What it the correct format for “+zone”

Im having the same problem, it was very odd and it took me a while to figure it out.

Im getting a null error code and the error messages is “Unable to adapt response to objetctName”. The catch was, the data was saved. including the date time.

I remove parameters one by one, so I figure the date was the problem.

Couldnt figure it out, why the date was wrong, cause I read the formatting docs and everything seems to be fine. So now just by luck I see there is also a “+zone” which is very hard to see in laptop.

Im sending this “06/20/1986 00:00:00”, what should I append to it for the +zone.

Thanks :slight_smile:

Hi Erick,

Here’s an example of a value which you can enter into console (note that the only way to enter it into console is by copy/paste, you cannot just type it in, there appears to be a bug with entry validation).

10/15/2015 00:00 -0700

Once you enter and save the data (you need to explicitly click the pencil icon on the very right of the record), the data is saved and will be displayed in the GMT-0 timezone. Console displays all dates in GMT-0.

When you save new objects using API, you can use the same format for the time zone.

Regards,
Mark

Hello Mark

Thanks for the quick reply but I try to post that and got the same null error code and error message “Unable do adapt response to Diligence”.

This is the code (deadline is a String Im working on Android):

Backendless.UserService.CurrentUser();

Diligence diligence = new Diligence();
diligence.setName("well user is changing");
diligence.setDescription("but but I keep getting the error");
diligence.setDeadline("10/15/2015 00:00 -0700");
diligence.setPreparation_time(2);

Backendless.Persistence.save(diligence, new AsyncCallback<Diligence>() {
    @Override
    public void handleResponse(Diligence response) {
        Log.d(GlobalApplication.APP_TAG_NAME, "success");
        Toast toast = Toast.makeText(getApplicationContext(), "success", Toast.LENGTH_LONG);
        toast.show();
    }

    @Override
    public void handleFault(BackendlessFault fault) {
        Log.d(GlobalApplication.APP_TAG_NAME, "error code = " + fault.getCode());
        Toast toast = Toast.makeText(getApplicationContext(), fault.getMessage(), Toast.LENGTH_LONG);
        toast.show();
    }
});

Just in case, Im avoiding to use the autogenerated code provided cause I want to actually understand how my app works.What am I doing wrong?

Could you please post the code for the Diligence class?

No problem

package cl.cutiko.diadelpicoapp.BackendLess.Data;

/**
 * Created by cutiko on 11-10-2015.
 */
public class Diligence {

 private String objectId, name, description, deadline;
 private int preparation_time;

 public String getObjectId()
 {
 return objectId;
 }

 public void setObjectId( String objectId )
 {
 this.objectId = objectId;
 }

 public String getName() {
 return name;
 }

 public void setName(String name) {
 this.name = name;
 }

 public String getDescription() {
 return description;
 }

 public void setDescription(String description) {
 this.description = description;
 }

 public String getDeadline() {
 return deadline;
 }

 public void setDeadline(String deadline) {
 this.deadline = deadline;
 }

 public int getPreparation_time() {
 return preparation_time;
 }

 public void setPreparation_time(int preparation_time) {
 this.preparation_time = preparation_time;
 }
}

I can upload the project to github if you want to, thanks for helping me, this is driving me crazy.

How about changing the “deadline” type to java.utilizing.Date? Also try saving with Backendless.Persience.of( Diligence.class ).save

Regards,
Mark

Greetings

Fixed! The problem is the date datatype, should be a Java.util.Date. Just to be sure I test getting the date and then transforming it to a String, same error. Thanks.

How ever Im not sure if this good or not, cause this means that getting objects by date will be using Java.util.Date, also Im wondering what is going to happen when I implement a date picker (cant remember now how thoose works).

Anyway, problem fixed for now.

Greetings

So Im glad the forum is actually usefull, I decide to make usefull myself. As you can read above the DateTime should be save using a utils.Date datatype. This is kind of troublesome cause a normal datepicker in Android produce integers as the selected date (1 integer variable for year, 1 for month and 1 for day). So Im giving you a code example here so you can easily transform the datepicker selected date into a utils.Date object:

DatePickerDialog.OnDateSetListener createDatePicker = new  DatePickerDialog.OnDateSetListener(){
    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {


        Calendar calendar = new GregorianCalendar(year, monthOfYear, dayOfMonth);
        Date date = calendar.getTime();
        YourObject yourObject = new YourObject();
        yourObject.setDateObject(date);
    }
};

Here Im doing this inside a onDateSet, which means you will have to find the must suitable way for implementing the datepicker according to your project. Also Im starting the object to be saved inside the onDateSet, but you can do it somewhere else. And setDateObject is the variable which correspond to a datetime in the backendless database.

Hope to be helpfull :slight_smile:

Thanks, Erick! I am sure other developers will find it very helpful.

Regards,
Mark

Welcome, Im gonna do my best to help all I can :slight_smile: see you arround, hugs.

how to convert java date object to datetime?

How can I store local time in backendless database? Must it be stored in the datetime table column? If yes, how do I store it since most methods in java.util.Date package are deprecated.

I want to store time values like 6:25pm as either 06:25 PM or 18:25 or even 18:25:59 (with the seconds).