我在angularjs应用中使用bootstrap-ui-datetime-picker。但我无法在时间选择器中获得24小时格式。在我选择下午6:00结果后,我得到18:00 h。这没关系,但我也需要直接选择器。 这是代码
Scanner input = new Scanner(System.in);
public static void main(String[] args) {
String[] rodent;
String[] dog;
String[] cat;
rodent = new String[] {"Rat", "Guinea Pig", "Mouse"};
dog = new String[] {"Rottweiler", "Basset Hound", "Weiner Dog"};
cat = new String[] {"Lion", "Tiger", "Mountain Lion"};
Scanner input = new Scanner(System.in);
System.out.print("Please Enter [R] for Rodent, [D] for Dogs, and"
+ " [C] for Cats: ");
char character = input.next().charAt(0);
switch (character){
case 'R': System.out.print(rodent[0]+", "+rodent[1]+", "+rodent[2]);break;
case 'D': System.out.print(dog[0]+", "+dog[1]+", "+dog[2]);break;
case 'C': System.out.print(cat[0]+", "+cat[1]+", "+cat[2]);break;
}
}
工作plnkr遇到同样的问题 谢谢
答案 0 :(得分:1)
您需要将配置对象解析为timepicker-options
属性并设置showMeridian: false
。这将禁用AM / PM模式并启用24h模式。
<div ng-controller="MyCtrl as ctrl">
<input type="text"
class="form-control"
datetime-picker="MM/dd/yyyy HH:mm"
timepicker-options="ctrl.datePickerOptions"
ng-model="ctrl.date.value" is-open="ctrl.date.showFlag" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="ctrl.date.showFlag = true">
Open picker
</button>
</span>
</div>
var myApp = angular.module('myApp', ['ui.bootstrap', 'ui.bootstrap.datetimepicker']);
myApp.controller('MyCtrl', function($scope) {
var that = this;
this.datePickerOptions = {
showMeridian: false
}
this.date = {
value: new Date(),
showFlag: false
};
this.openCalendar = function(e, date) {
that.open[date] = true;
};
});
<强>&GT; demo fiddle 强>