小编use*_*180的帖子

getRelativeTimeSpanString的默认语言环境

我使用以下方法覆盖我的应用的区域设置:

 Locale locale = new Locale("ca");
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());
Run Code Online (Sandbox Code Playgroud)

但它似乎getRelativeTimeSpanString不适用于应用程序上下文,而是使用系统区域设置.

datetime android locale relative-date

11
推荐指数
2
解决办法
5102
查看次数

如何使用mongoose native promise(mpromise)查找文档然后保存

我正在尝试重构回调地狱的承诺.如何使用findById.exe()然后object.save()使用promises?

exports.changeAnimalName = function(req, res) {
 var Animal = mongoose.model('Animal', animalSchema);

 Animal.findById(id, function (err, animal) {
  if (animal) {
   animal.name=req.body.name;
   animal.save(function (err, animalSaved) {
    if (err) return console.error(err);
     return res.send(animalSaved);
    });
   }
 });
}
Run Code Online (Sandbox Code Playgroud)

mongoose node.js promise express

1
推荐指数
1
解决办法
2374
查看次数