所以我从表单中的传入对象获取日期属性:
Tue May 24 05:05:16 EDT 2011
Run Code Online (Sandbox Code Playgroud)
我正在编写一个简单的帮助方法将其转换为日历方法,我使用以下代码:
public static Calendar DateToCalendar(Date date )
{
Calendar cal = null;
try {
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
date = (Date)formatter.parse(date.toString());
cal=Calendar.getInstance();
cal.setTime(date);
}
catch (ParseException e)
{
System.out.println("Exception :"+e);
}
return cal;
}
Run Code Online (Sandbox Code Playgroud)
为了模拟传入的对象,我只是在当前使用的代码中分配值:
private Date m_lastActivityDate = new Date();
Run Code Online (Sandbox Code Playgroud)
然而,一旦该方法到达,这将给我一个空指针:
date = (Date)formatter.parse(date.toString());
Run Code Online (Sandbox Code Playgroud) 我将我的maven项目设置为1个shell项目和4个子模块.当我尝试构建shell时.我明白了:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project module1:1.0_A0 (C:\module1\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find shell:pom:1.0_A0 in http://nyhub1.ny.ssmb.com:8081/nexus/content/repositories/JBoss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]
Run Code Online (Sandbox Code Playgroud)
如果我尝试构建一个单独的模块,我得到相同的错误只替换module1,无论它是什么模块.
让他们都在他们的poms中引用父母.
<parent>
<artifactId>shell</artifactId>
<groupId>converter</groupId>
<version>1.0_A0</version>
</parent> …Run Code Online (Sandbox Code Playgroud) 将Object转换为double并注意到这两种方法.我看到parseDouble从1.2开始就已经存在了.为什么添加此方法,如果它基本上与valueOf(s)功能相同?
我的印象是
rm -r *.xml
Run Code Online (Sandbox Code Playgroud)
会删除父母和孩子的所有文件:
*.xml: No such file or directory
Run Code Online (Sandbox Code Playgroud) 我需要一个Xpath表达式来选择以某个值开头的值.对于此实例,我使用id字段.
@id=[starts-with(name(),'value')
Run Code Online (Sandbox Code Playgroud)
以下不起作用.有没有办法使用带有标签之间值的starts-with命令?或者在xpath中有另一种选择匹配具有已知值的值的方法.
这是我想要深入研究的xml示例:
<bean>
<id>AnnotationsBasedJMXAutoExporter</id>
<class>org.springframework.jmx.export.MBeanExporter</class>
<lazy-init>false</lazy-init>
<property>assembler
<!-- will create management interface using annotation metadata -->
<bean>
Run Code Online (Sandbox Code Playgroud) 在java中我想知道哪些更有效:
if(something)
{
if(something)
}
Run Code Online (Sandbox Code Playgroud)
要么
if((something) &&(something))
Run Code Online (Sandbox Code Playgroud)
我想知道两者在性能方面的优点是什么.哪种解决方案更适合不同的数据对象.
好的,我正在尝试将mavenise作为一个项目.但是我的项目找不到包含一些bean的xml文件.combined2.xml
我把它定义为:
public RepeatingGrpPoC() {
appContext = new ClassPathXmlApplicationContext(
new String[] { "src/main/java/resources/combined2.xml",});
c = 0;
}
Run Code Online (Sandbox Code Playgroud)
然而,由于我不知道的原因,我不断得到错误.
public RepeatingGrpPoC() {
appContext = new ClassPathXmlApplicationContext(
new String[] { "src/main/java/resources/combined2.xml",});
c = 0;
}
Run Code Online (Sandbox Code Playgroud)
引起:java.io.FileNotFoundException:类路径资源[src/main/java/resources/combined2.xml]无法打开,因为org.springframework.core.io.ClassPathResource.getInputStream中不存在(ClassPathResource.java: 141)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)... 14更多
程序在哪里寻找这个文件,因为我已经给它相对路径?
我有许多setter方法,它们采用枚举.这些基于传入对象属性.而不是写一堆这些是有一种方法来必须硬编码说10个不同的案例陈述.有没有办法创建一个可重用的方法?
//Side class declared as
public final enum Side
//How I initialise side
static Side side = Side.SELL;//default
//method to set object
Obj.setSide(sideEnum(zasAlloc.getM_buySellCode()));
//How I am implementing it
public static Side sideEnum(String buysell)
{
if(buysell.equalsIgnoreCase("S"))
{
side = Side.SELL; //default
}
else if(buysell.equalsIgnoreCase("B"))
{
side = Side.BUY;
}
return side;
}
Run Code Online (Sandbox Code Playgroud) 如何创建/实例化一个数组,使其等于另一个数组的子字符串,其中子字符串的大小未知:
int n; //some number derived somewhere else
String[] grp = elements[i] to elements[i+n];
Run Code Online (Sandbox Code Playgroud) 从我的 junit 测试中,我调用一个简单的方法来清除我的表:
@AfterClass
public static void runAfterClass() {
//Clear db contents after tests
// NOTE this clears ALL data from the table
try {
System.out.println("deleting db contents");
HibFunction.clearTable();
} catch (Exception e) {
System.out.println("Couldnt delete db contents");
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
清除表看起来像:
public static void clearTable()
{
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
try{
transaction = session.beginTransaction();
session.createQuery("delete from metadataPoC.hib.TestHib").executeUpdate();
transaction.commit();
}catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
}
Run Code Online (Sandbox Code Playgroud)
所有相当简单的东西,但我的控制台输出仅此而已:
deleting db contents
Run Code Online (Sandbox Code Playgroud)
我不确定为什么一个简单的delete …