[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: date formating

Subject: Re: date formating
From: Samina Islam <samnaz123@xxxxxxxxx>
Date: Fri, 17 Aug 2001 11:41:57 -0700 (PDT)
samina islam
Hi All, 

For some reason the parse method in SimpleDateFormat
class is not recognizing harvest_time value as a valid
string.  Does anyone know why?  It is giving me a
runtime error that says:

javax.xml.transform.TransformerException: Cannot
format given Object as a Date.  


Again, my XML document looks like this:
<moreovernews>
  <article id="_23314341">
    <url>http://c.moreover.com/</url> 
    <harvest_time>Aug 15 2001 1:07PM</harvest_time> 
  </article>

... 

In my XSL stylesheet I have this:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:DateFormat="myDateFormat"
    extension-element-prefixes="DateFormat">

...

<xsl:variable name="moreover-date"   
      select="harvest_time" />		
<xsl:value-of select= "DateFormat:transformDate(
        $moreover-date, 
        'yyyy-MM-dd&apos;T&apos;HH:mm:ssz',
        'MMM dd yyyy hh:mma' )" />

...


myDateFormat java class looks like this:

import java.util.*;
import java.text.*;

public class myDateFormat {
	
   public SimpleDateFormat init(
            String isoDate, 
            TimeZone tz) {
     
       SimpleDateFormat prismDate = new   
           SimpleDateFormat(isoDate);
       prismDate.setTimeZone(tz);
       return prismDate;
   }
   
   public String transformDate(
            String moreoverTime, 
            String isoDateFormat, 
            String oldDateFormat) {

       SimpleDateFormat moreoverDate = new 
            SimpleDateFormat(oldDateFormat);
       
       TimeZone tz = new SimpleTimeZone(0, "Z");
       SimpleDateFormat prismDate = 
             this.init(isoDateFormat,tz);
		
       ParsePosition pp = new ParsePosition(0);
       moreoverDate.parse(moreoverTime, pp);
       String isoDate =
prismDate.format(moreoverTime);

       return isoDate;
   }
}

Any suggestions on why this is happening will be
great!!  Thanks!

Samina

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.