我正在使用改造。我从服务器获取数据(日期和时间)。但是创建日期是 (2016-01-22 15:22:37)
。我只想显示日期 (2016-01-22)
。
user = StoreUtil.getInstance().selectFrom("users");
NetworkEngine.getInstance().getNotSending(user.getId(), new Callback<List<MyPending>>() {
@Override
public void success(List<MyPending> myPendings, Response response) {
txt_taker_name.setText(getResources().getString(R.string.str_taker_name)
+ ":" + " " + myPendings.get(0).getShippingInformation().getName());
txt_taker_address.setText(getResources().getString(R.string.str_taker_address)
+ ":" + " " + myPendings.get(0).getShippingInformation().getAddress());
txt_cargo_name.setText(getResources().getString(R.string.str_cargo_name)
+ ":" + " " + myPendings.get(0).getShippingTransactionDetail().get(0).getCargo().getName());
txt_cargo_qty.setText(getResources().getString(R.string.str_cargo_qty)
+ ":" + " " + myPendings.get(0).getShippingTransactionDetail().get(0).getCargo().getQuantity());
txt_total_weight.setText(getResources().getString(R.string.str_confirm_totalweight)
+ ":" + " " + myPendings.get(0).getTotalWeight());
txt_total_deliver_charges.setText(getResources().getString(R.string.str_confirm_totalcharges)
+ ":" + " " + myPendings.get(0).getTotalCost());
String date = new SimpleDateFormat("yyyy-MM-dd").format(
myPendings.get(0).getShippingTransactionDetail().get(0).getCargo().getCreatedAt());
txt_deliver_date.setText(getResources().getString(R.string.str_deliver_date) + ":" + " " + date);
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
dialog.dismissWithFailure();
}
});
最佳答案
简单的方法就是拆分日期
String dates = myPendings.get(0).getShippingTransactionDetail().get(0).getCargo().getCreatedAt();
if(!dates.equalsIgnoreCase("")){
String date[] = dates.split(" ");
Log.e("FINAL DATE-->","-->"+date[0]);
}
关于android - 如何仅在android中获取用户创建日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35077131/