使用Joda时间将12小时时间转换为24小时

时间:2017-02-09 08:46:48

标签: android datetime jodatime joda-convert

我收到此错误 格式无效:" 09:30 PM"在" PM"

LocalTime start = new LocalTime();
LocalTime end = new LocalTime();
DateTimeFormatter formatter = DateTimeFormat.forPattern("hh:mm a");
start = formatter.parseLocalTime(from.toLowerCase());
end = formatter.parseLocalTime(to.toLowerCase());

1 个答案:

答案 0 :(得分:0)

您的图案不正确。请使用以下内容:

from django.shortcuts import render
from django.http import HttpResponse
from app.models import *
# Create your views here.

def collegeview(request):

    if request.method == 'POST':
        form = collegeform(requst.POST)
        if form.is_valid():
            form.save()
            return HttpResponse('its done here')
        else:
            form = collegeform()
            return render(request, 'about.html', {'form':form})                

def schoolview(request):

    if request.method == 'POST':
        f = schoolform(requst.POST)
        if f.is_valid():
            f.save()
            return HttpResponse('its done here')
        else:
            f = schoolform()
            return render(request, 'about.html', {'f':f})

修改:这是指向Documentation for DateTimeFormat的链接。