@Override
public void onBackPressed() {
// TODO Auto-generated method stub
PopIt("Exit Application", "Are you sure you want to exit?");
super.onBackPressed();
}
public void PopIt( String title, String message ){
new AlertDialog.Builder(this)
.setTitle( title )
.setMessage( message )
.setPositiveButton("YES", new OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1) {
//do stuff onclick of YES
finish();
}
}).setNegativeButton("NO", new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
//do stuff onclick of CANCEL
Toast.makeText(getBaseContext(), "You touched CANCEL", Toast.LENGTH_SHORT).show();
}
}).show();
}
Run Code Online (Sandbox Code Playgroud)
这个警报对话框速度太快,我无法阅读或点击它!这是为什么 …
我在文本文件中有一个句子,我想在 python 中显示,但我想显示它,以便在每个句号(句点)之后开始一个新行。
\n\n例如我的段落是
\n\n"Dr. Harrison bought bargain.co.uk for 2.5 million pounds, i.e. he\npaid a lot for it. Did he mind? John Smith, Esq. thinks he didn\'t.\nNevertheless, this isn\'t true... Well, with a probability of .9 it\nisn\'t."\nRun Code Online (Sandbox Code Playgroud)\n\n但我希望它显示如下
\n\n"Dr. Harrison bought bargain.co.uk for 2.5 million pounds, i.e. he\npaid a lot for it. \nDid he mind? John Smith, Esq. thinks he didn\'t. \nNevertheless, this isn\'t true... \nWell, with a probability of .9 it isn\xe2\x80\x99t."\nRun Code Online (Sandbox Code Playgroud)\n\n句子中出现的其他句号(例如网站地址中的“Dr.”、“Esq.”、“.9”,当然还有前两个句号)使得这一点变得越来越困难。省略号中的点。
\n\n …所以我有2个日期选择器用于开始和结束时间,它们返回DateTime.
我需要以"小时小时分钟"的格式计算这两次之间的持续时间,例如,"1小时30分钟".如果有天差,它将显示"24小时",因此我们使用小时而不是天.
我遇到的问题是,无论我如何工作,如果用户提前选择一个月,它就会中断.他们永远不应该选择一个月,但可以选择.
我收到此错误:
java.lang.UnsupportedOperationException: Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: P1M3W6DT1H
at org.joda.time.Period.normalizedStandard(Period.java:1640)
Run Code Online (Sandbox Code Playgroud)
我的代码是:
Period durationHoursAndMinutes = new Period(startDate.toLocalDateTime(), endDate.toLocalDateTime()).normalizedStandard(PeriodType.time());
PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendHours()
.appendSuffix(getResources().getString(R.string.mytrips_tripview_rail_waitTime_hr))
.appendSeparator(" ")
.appendMinutes()
.appendSuffix(getResources().getString(R.string.mytrips_tripview_rail_waitTime_min))
.toFormatter();
if(durationHoursAndMinutes.getMinutes() > 0){
return formatter.print(durationHoursAndMinutes);
}else {
return null;
}
Run Code Online (Sandbox Code Playgroud)
我查看了PeriodType的代码,它说如果月份!= 0则抛出异常,它不会.只是想知道我是否有办法解决这个问题.谢谢你的帮助
如果我计算2的区别LocalDate在的java.time使用:
Period p = Period.between(testDate, today);
Run Code Online (Sandbox Code Playgroud)
然后我得到一个年,月,天数的输出,如:
Days = 9
Months = 6
Years = 18
Run Code Online (Sandbox Code Playgroud)
有没有人知道一种干净的方式来表示作为十进制类型的值(即上面会是什么18.5...)?
我试图在每个'.'分割一个字符串.(句点),但句点是java正则表达式使用的符号.示例代码,
String outstr = "Apis dubli hre. Agro duli demmos,".split(".");
Run Code Online (Sandbox Code Playgroud)
我无法摆脱句号角色,那么我怎么让Java忽略它?
如果我这样编码:
Period wrong = Period.ofYears(1).ofWeeks(1);
Run Code Online (Sandbox Code Playgroud)
它给出了输出P7D.
通过Period类的实现,我们知道所有of____()方法都是静态的.
但是,如果你与DateTime班级做同样的链接:
LocalDate date = LocalDate.of(2020, Month.JANUARY, 20);
LocalTime time = LocalTime.of(5, 15);
LocalDateTime dateTime = LocalDateTime.of(date, time)
.minusDays(1).minusHours(10).minusSeconds(30);
Run Code Online (Sandbox Code Playgroud)
All minus___()和plus___()方法是LocalDateTime类中的实例方法.
问题:为什么课程不允许进行方法链接Period?
为什么Period班级不支持?
内部任务如何进行?