如何使用Android将日期数据类型的日期放入parse.com?

时间:2015-12-16 11:14:55

标签: android parse-platform

ParseQuery<ParseObject> query = ParseQuery.getQuery("User");
query.whereEqualTo("Username", textresult.getText().toString());
Jquery.getFirstInBackground(new GetCallback<ParseObject>()
    {   
    @Override
    public void done(ParseObject user, ParseException e) {
        if(e == null)
        {
            user.put("DateUsed", "2015-12-1 2:00:00");
            user.saveInBackground();
            Toast.makeText(getApplicationContext(),"Cliffy!",Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(getApplicationContext(),"Cant'Send!",Toast.LENGTH_SHORT).show();
        }
    }
});

我不知道如何将数据插入我的解析表中的格式或语法。

2 个答案:

答案 0 :(得分:0)

这可能有效:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2015);
cal.set(Calendar.MONTH, 12);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY,2);
cal.set(Calendar.MINUTE,00);
cal.set(Calendar.SECOND,0);
cal.set(Calendar.MILLISECOND,0);

Date myDate = cal.getTime();
user.put("DateUsed", myDate);

答案 1 :(得分:0)

使用此代码,

 java.util.Date subdate; 
       try {
          subdate=object.getDate("date");
          DateFormat df = new SimpleDateFormat("MMM dd, yyyy, kk:mm", Locale.ENGLISH);
          String subdateStr = df.format(subdate);
          date.setText(subdateStr);
        } catch(Exception ex) {
          // log error
        }