String dt = "yyyy-MM-dd'T'HH:mm:ss'.'SSSZZZZZ";
SimpleDateFormat sdf = new SimpleDateFormat(dt);
String outDateString = source.substring(0, 26) + source.substring(27, 29);
Date outDate = sdf.parse(outDateString);
Wednesday, December 3, 2008
Converting Date from xml unmarshalled format to the standard representation.
Converting from "2008-12-03T12:46:35.896+02:00" to "Wed Dec 03 12:46:35 GMT+02:00 2008".
Convert a String into an Element
Convert a String into an InputStream
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
StringBuffer stringBuffer1 = new StringBuffer("2008-12-03T13:24:00.408+02:00 ");
ByteArrayInputStream bis1 = new ByteArrayInputStream(stringBuffer1.toString()
.getBytes("UTF-8"));Convert an InputStream into DocumentDocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(bis1);
As a result of Element
org.w3c.dom.ElementmessageElement = document.getDocumentElement();
Tuesday, December 2, 2008
Антран плагины: нельзя два в одном и как проверить проперть
Если вы напишете в поме два плагина антран, то будет валидный только второй.
Вот пример:
===\/=====================================
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>000</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 000 ===</echo>
<echo>=== ECHO === 000 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>0</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 0 ===</echo>
<echo>=== ECHO === 0 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
===/\=====================================
Результат работы:
[INFO] [clean:clean]
[INFO] [antrun:run {execution: 0}]
[INFO] Executing tasks
[echo] === ECHO === [/home/alexey/java/eXoProjects/portlet-container/trunk/applications/tck-tests/target] ===
[echo] === ECHO === 0 ===
[echo] === ECHO === 0 ===
[INFO] Executed tasks
Кстати, таким образом антран плагином можно проверить наличие системной проперти при помощи ECHO!
Вот пример:
===\/=====================================
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>000</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 000 ===</echo>
<echo>=== ECHO === 000 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>0</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 0 ===</echo>
<echo>=== ECHO === 0 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
===/\=====================================
Результат работы:
[INFO] [clean:clean]
[INFO] [antrun:run {execution: 0}]
[INFO] Executing tasks
[echo] === ECHO === [/home/alexey/java/eXoProjects/portlet-container/trunk/applications/tck-tests/target] ===
[echo] === ECHO === 0 ===
[echo] === ECHO === 0 ===
[INFO] Executed tasks
Кстати, таким образом антран плагином можно проверить наличие системной проперти при помощи ECHO!
Subscribe to:
Posts (Atom)