shivashankarHg shankar

Greenhorn
+ Follow
since Jun 26, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by shivashankarHg shankar

Dear All, Thanks for the reply....

Regards
Shiva

14 years ago
Dear All,

I want the year and Month from the following date format.

I am obtaining the DATE from spinner, which is of following format
"MMM/YYYY" from client side swings.

i want to retrieve the Month ,

Here is the code

public getMonth(String monthYearSelected, int weekSelected)
{
this.monthYearSelected = monthYearSelected;
Calendar nederlandCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
try {
System.out.println("Spinner Date :"monthYearSelected);
Date date = format.parse(monthYearSelected);
System.out.println("Parsed Date :" date);
nederlandCal.setTimeInMillis(date.getTime());
System.out.println("Month is:"(nederlandCal.get(Calendar.MONTH)+1));
} catch (ParseException e1) {
e1.printStackTrace();
}
}


output:
Spinner Date :Mon Jun 01 00:00:00 GMT+05:30 2009
Parsed Date :Mon Jun 01 00:00:00 GMT+05:30 2009
Month is:5

But Ideally, I should get 6(For June),


I have a similar kind of issues for Year too


Calendar nederlandCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
Calendar previous = new GregorianCalendar(TimeZone.getTimeZone("Netherland"));
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
try {
System.out.println("Spinner Date :"+yearSelected);
Date date = format.parse(yearSelected);
System.out.println("Parsed Date :" date);
//nederlandCal.setTime(date);
nederlandCal.setTimeInMillis(date.getTime());
System.out.println("Year is :"+nederlandCal.get(Calendar.YEAR));
} catch (ParseException e1) {
e1.printStackTrace();
}

output:
Spinner Date :Tue Jan 01 00:00:00 GMT+05:30 2008
Parsed Date :Tue Jan 01 00:00:00 GMT+05:30 2008
Year is :2007

But, I should get 2008

I have tried both setTime() and setTimeInMillis(), but none is giving me the proper results

Am i wrong any where....?... Can anybody give me better idea

Kindly help

Regards
Shiva

14 years ago
I have a simple xml files with the following tags, having some non-english characters,

<?xml version="1.0" encoding="UTF-8"?>
<LocationItems>
<Location>
<locationID>1</locationID>
<title>Pakketservice Belgiƫ</title>
</Location>
</LocationItems>

and reading the xml with the folowing code,

DocumentBuilderFactory dbfact = DocumentBuilderFactory.newInstance();
DocumentBuilder dbuild = dbfact.newDocumentBuilder();
String path = application.getRealPath("/")+"XMLs/Locations.xml";
Document dc = dbuild.parse (new File(path));

and, i am getting the following error message


com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 3-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.apache.jsp.locations_jsp._jspService(locations_jsp.java:381)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)



--------

The online solutions are not specific.

some body suggested me to use the following encoding format,

<?xml version="1.0" encoding="ISO-8859-1"?>

but this also not working..... Can anybody help me in this regard, hw to resolve the issue...?
14 years ago