我尝试构建一个应用程序,该应用程序应该给出维也纳当地时间。我格式化了时间time = DateFormat.jm().format(),但现在我得到了一个类似的时间14:25 PM。我怎样才能删除PM,因为我不需要\xc2\xb4t?\n这是我尝试过的代码:
class _MyHomePageState extends State<MyHomePage> {\n void getTime() async {\n String time;\n\n Response response =\n await get("http://worldtimeapi.org/api/timezone/Europe/Vienna");\n Map data = jsonDecode(response.body);\n\n String datetime = data["datetime"];\n String offset = data["utc_offset"].substring(1, 3);\n DateTime now = DateTime.parse(datetime);\n now = now.add(Duration(hours: int.parse(offset)));\n time = DateFormat.jm().format(now);\n print(time);\n }\nRun Code Online (Sandbox Code Playgroud)\n这是我得到的时间:
\nI/flutter ( 9302): 12:43 PM\nRun Code Online (Sandbox Code Playgroud)\n