[英]I am having problem when i am trying to assign String data to Integer variable
String showYear;
String showMonth;
String showDay;
int showDayIntVersion;
Future getNepaliDate() async {
NepaliDateTime _selectedDateTime = await picker.showAdaptiveDatePicker(
context: context,
initialDate: NepaliDateTime.now(),
firstDate: NepaliDateTime(2000),
lastDate: NepaliDateTime.now()
);
setState(() {
showYear = DateFormat("yyyy").format(DateTime.parse(_selectedDateTime.toString()));
showMonth = DateFormat("MM").format(DateTime.parse(_selectedDateTime.toString()));
showDay =DateFormat("dd").format(DateTime.parse(_selectedDateTime.toString()));
showDayIntVersion= int.parse(showDay);
});
}
#in my showYear i get 2022, in showMonth i get 04 and in showDay i get 02 but when i assign showDay to showDayIntVersion i only get 2 and due to it gives invalid date format day dateTime format and i have my reasons to assign showDay to showDayIntVersion need help thanks #在我的 showYear 中我得到 2022,在 showMonth 中我得到 04,在 showDay 中我得到 02 但是当我将 showDay 分配给 showDayIntVersion 我只得到 2 并且由于它给出了无效的日期格式日 dateTime 格式并且我有理由将 showDay 分配给showDayIntVersion 需要帮助谢谢
if you want to show string as int then do like this:如果你想将字符串显示为 int 然后这样做:
int.parse(showday);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.