当我将数据插入MongoDB集合时,当我使用python插入集合时,我在集合中的某个日期字段上有@Override
public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int position) {
String name, langId, type, lang, courseCategoryName;
if (shortTermCoursesModels.get(position).getName() != null
&& !shortTermCoursesModels.get(position).getName().isEmpty()) {
name = shortTermCoursesModels.get(position).getName();
} else {
name = "---";
}
if (shortTermCoursesModels.get(position).getLanguageSymbol() != null
&& !shortTermCoursesModels.get(position).getLanguageSymbol().isEmpty()) {
langId = shortTermCoursesModels.get(position).getLanguageSymbol();
} else {
langId = "fa";
}
if (shortTermCoursesModels.get(position).getType() != null
&& !shortTermCoursesModels.get(position).getType().isEmpty()) {
type = shortTermCoursesModels.get(position).getType();
if (type.equalsIgnoreCase(context.getString(R.string.live))) {
type = context.getString(R.string.title_live);
} else if (type.equalsIgnoreCase(context.getString(R.string.one_lesson))) {
type = context.getString(R.string.title_one_lesson);
} else if (type.equalsIgnoreCase(context.getString(R.string.modular))) {
type = context.getString(R.string.title_modular);
}
} else {
type = "---";
}
if (shortTermCoursesModels.get(position).getCourseCategoryName() != null
&& !shortTermCoursesModels.get(position).getCourseCategoryName().isEmpty()) {
courseCategoryName = shortTermCoursesModels.get(position).getCourseCategoryName();
} else {
courseCategoryName = "---";
}
switch (langId) {
case "fa":
lang = context.getString(R.string.Persian);
break;
case "en":
lang = context.getString(R.string.English);
break;
case "ur":
lang = context.getString(R.string.Urdu);
break;
case "ar":
lang = context.getString(R.string.Arabia);
break;
case "az":
lang = context.getString(R.string.Azari);
break;
case "tr":
lang = context.getString(R.string.Turkish);
break;
case "fr":
lang = context.getString(R.string.France);
break;
case "es":
lang = context.getString(R.string.Español);
break;
case "id":
lang = context.getString(R.string.Indonesian);
break;
case "ha":
lang = context.getString(R.string.hausa);
break;
case "ru":
lang = context.getString(R.string.Pусский);
break;
default:
lang = "";
break;
}
boolean reverseLayout = langId.equalsIgnoreCase("fa") || langId.equalsIgnoreCase("ur") || langId.equalsIgnoreCase("ar");
RelativeLayout.LayoutParams paramsTxtSubject = (RelativeLayout.LayoutParams) viewHolder.txtSubject.getLayoutParams();
RelativeLayout.LayoutParams paramsTxtTypeCourse = (RelativeLayout.LayoutParams) viewHolder.txtTypeCourse.getLayoutParams();
RelativeLayout.LayoutParams paramsTxtLang = (RelativeLayout.LayoutParams) viewHolder.txtLang.getLayoutParams();
RelativeLayout.LayoutParams paramsTxtCourseCategoryName = (RelativeLayout.LayoutParams) viewHolder.txtCourseCategoryName.getLayoutParams();
if (reverseLayout) {
paramsTxtSubject.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
viewHolder.txtSubject.setGravity(Gravity.RIGHT);
viewHolder.txtSubject.setPadding(30, 0, 30, 0);
viewHolder.txtSubject.setText(name);
paramsTxtTypeCourse.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
viewHolder.txtTypeCourse.setGravity(Gravity.RIGHT);
viewHolder.txtTypeCourse.setPadding(30, 0, 30, 0);
viewHolder.txtTypeCourse.setText(type);
paramsTxtLang.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
viewHolder.txtLang.setGravity(Gravity.LEFT);
viewHolder.txtLang.setPadding(30, 0, 30, 0);
viewHolder.txtLang.setText(lang);
paramsTxtCourseCategoryName.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
viewHolder.txtCourseCategoryName.setGravity(Gravity.RIGHT);
viewHolder.txtCourseCategoryName.setPadding(30, 0, 30, 0);
viewHolder.txtCourseCategoryName.setText(courseCategoryName);
try {
FontCustoms.setFontCustomTVBold(context, viewHolder.txtSubject, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtTypeCourse, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtLang, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtCourseCategoryName, langId);
} catch (Exception ignored) {
Throwable t = new Throwable(ignored).fillInStackTrace();
FirebaseCrash.report(t);
}
} else {
paramsTxtSubject.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
viewHolder.txtSubject.setGravity(Gravity.LEFT);
viewHolder.txtSubject.setPadding(30, 0, 30, 0);
viewHolder.txtSubject.setText(name);
paramsTxtTypeCourse.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
viewHolder.txtTypeCourse.setGravity(Gravity.LEFT);
viewHolder.txtTypeCourse.setPadding(30, 0, 30, 0);
viewHolder.txtTypeCourse.setText(type);
paramsTxtLang.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
viewHolder.txtLang.setGravity(Gravity.RIGHT);
viewHolder.txtLang.setPadding(30, 0, 30, 0);
viewHolder.txtLang.setText(lang);
paramsTxtCourseCategoryName.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
viewHolder.txtCourseCategoryName.setGravity(Gravity.LEFT);
viewHolder.txtCourseCategoryName.setPadding(30, 0, 30, 0);
viewHolder.txtCourseCategoryName.setText(courseCategoryName);
try {
FontCustoms.setFontCustomTVBold(context, viewHolder.txtSubject, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtTypeCourse, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtLang, langId);
FontCustoms.setFontCustomTVNormal(context, viewHolder.txtCourseCategoryName, langId);
} catch (Exception ignored) {
Throwable t = new Throwable(ignored).fillInStackTrace();
FirebaseCrash.report(t);
}
}
Glide.with(context)
.load(shortTermCoursesModels.get(position).getImageUrl())
.placeholder(ContextCompat.getDrawable(context, R.drawable.not_image))
.error(ContextCompat.getDrawable(context, R.drawable.not_image))
.centerCrop()
.into(viewHolder.imgCourseImage);
}
,到目前为止,由python手动插入的日期是相同的... >
但是我的收藏集中的“ updatedAt”字段比我的本地时间早2个小时... ISODate("2018-06-20T09:09:40.376Z")
我的不知道服务器/本地时差的客户,不知道在那种情况下如何正确查询“ updatedAt”字段...我怎么能意识到本地/ UTC或MongoDB服务器没有区别时间(无论是什么时间,我猜它是什么UTC?)...是否以某种方式自动进行了时区转换?
编辑:在我的查询URL路径中,我没有指出时区,我也必须给dd附加时区参数吗?在日期时间末尾像“ Z”?
我有这样的东西:"updatedAt" : ISODate("2018-06-20T07:09:40.381Z"),