Java - 它是一个编译器错误,什么时候是运行时异常?(Java - When is it a compiler error and when is it a runtime exception?)
我目前正在使用Sierra和Bates学习指南学习SCJP认证,并且在许多自测(模拟考题)中,我一直在遇到同样的问题 - 我无法分辨某个特定错误是否会在运行时出现(一个异常)或编译时(编译错误)。 我知道这是一个模糊的问题,它可能无法回答,但是,如何判断在编译时或运行时是否会发现错误? 你能给我发送一些可能能够帮助我的网站链接吗?
I am currently studying for the SCJP certification using the Sierra and Bates Study Guide and in many of the self tests (mock exam questions) I keep running into the same problem - I can't tell whether a particular error will be at runtime (an exception) or at compile (compile error). I know this is a bit of a vague question and that it might not be possible to answer but, how can I tell if an error will be found at compile or at runtime? Would you be able to send me some website links that might be able to help me?
原文:https://stackoverflow.com/questions/3179504
最满意答案
我认为你的意思是用户不能在10年之前添加任何日期吗? 或者您的用户大多是10到0岁的孩子?!
由于您的限制日期基于当前日期,因此您必须使用
setMinDate(long date)
和setMaxDate(long date)
以编程方式设置限制。 正如您所看到的那样,这些方法的工作日期为毫秒,因此您必须首先以毫秒为单位:Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, -10); //Goes 10 Year Back in time ^^ long upperLimit = calendar.getTimeInMillis(); //Get date in millisecond (epoch)
,然后使用上述方法设置限制:
datePicker.setMaxDate(upperLimit);
I think you mean users can't add any date earlier than 10 year before right? Or your users are mostly kids aged 10 to 0?!
Since your limit date is based on current date, you have to set limit programmatically using
setMinDate(long date)
andsetMaxDate(long date)
. As you can see those method works with date in millisecond so you have to get dare in millis first:Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, -10); //Goes 10 Year Back in time ^^ long upperLimit = calendar.getTimeInMillis(); //Get date in millisecond (epoch)
, and then set the limit using above method:
datePicker.setMaxDate(upperLimit);
相关问答
更多-
我想你不能有确切的思想。 dig.getDatePicker().setMinDate(minDate.getTime()+10); 这可能对你有帮助。 I found the solution: We have to put: minDate = ((ReservarTurnos)getActivity()).cc.getTime(); dig.getDatePicker().setMinDate(minDate.getTime()); before than: (( ...
-
通过datepicker方法和setDate创建datepicker $( "#datepicker" ).datepicker(); $("#datepicker").datepicker('setDate','01/01/1998'); http://codepen.io/nagasai/pen/kXyoqb Create the datepicker by datepicker method and setDate $( "#datepicker" ).datepicker(); $("#dat ...
-
请尝试这样的事情, $('#datepicker').datepicker({ dateFormat: 'dd/mm/yy', minDate: 0 }); 在jsfiddle演示 Please try something like this, $('#datepicker').datepicker({ dateFormat: 'dd/mm/yy', minDate: 0 }); demo in jsfiddle
-
我认为你的意思是用户不能在10年之前添加任何日期吗? 或者您的用户大多是10到0岁的孩子?! 由于您的限制日期基于当前日期,因此您必须使用setMinDate(long date)和setMaxDate(long date)以编程方式设置限制。 正如您所看到的那样,这些方法的工作日期为毫秒,因此您必须首先以毫秒为单位: Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.YEAR, -10); // ...
-
改变这个 yearRange: "-80:+0", 至 yearRange: "-80:+10", Change this yearRange: "-80:+0", to yearRange: "-80:+10",
-
Jquery Mobile Datepicker,选择日期和显示事件(Jquery Mobile Datepicker, Choose date and display events)[2022-05-29]
您可以使用jQM日期框,如下所示: 使用type="date"创建input并根据需要设置模式。 如果您想在用户设置后立即响应新日期,则可以为closeCallback添加回调。 function onClose(){ alert($('#D ... -
Android DatePicker Fragment会提前一个月返回日期(Android DatePicker Fragment returns date one month prior)[2021-10-13]
月份从0到12 。 从January到Undecimber 。 尝试将它们与Calendar."MONTH"进行比较Calendar."MONTH" 。 示例: Calendar.OCTOBER == 9 链接: http : //developer.android.com/reference/java/util/Calendar.html#MONTH 。 注意:如果您使用GregorianCalendar ,则可以忽略第13个月。 Months go from 0 to 12. From January ... -
我不确定这是不是你要找的,但我为你编了一个样本。 MainActivity.java public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activi ...
-
library(dplyr) library(lubridate) newdf <- df %>% filter(TransactionDate >= Sys.Date() - years(3)) library(dplyr) library(lubridate) newdf <- df %>% filter(TransactionDate >= Sys.Date() - years(3))
-
var availableDates = [9,14,15]; //desired Days function available(date) { dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear(); if ($.inArray(date.getDate(), availableDates) != -1) { return [true, "","Available"]; } ...