我使用以下方法覆盖我的应用的区域设置:
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不适用于应用程序上下文,而是使用系统区域设置.
我正在尝试重构回调地狱的承诺.如何使用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)