Re: [JAVA]Converting a string to date

2006-06-23 Thread [EMAIL PROTECTED]
Here is a good place to see Java by example.
http://www.kickjava.com/

Bryan LaPlante

-- Original Message ---
From: temp temp [EMAIL PROTECTED]
To: user@struts.apache.org
Sent: Thu, 22 Jun 2006 10:24:53 -0700 (PDT)
Subject: [JAVA]Converting a string to date

 I have a string which I want to convert into a date .
   The string   06-APR-07
 
   How can I convert this date into sql date ?
 
   Thanks
 
   
 -
 Yahoo! Groups gets better. Check out the new email design. Plus there’s much
more to come.
--- End of Original Message ---


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JAVA]Converting a string to date

2006-06-23 Thread Niall Pemberton

Commons Validator 1.3.0 has a whole set of easy to use
validation/conversion routines:

 http://tinyurl.com/g526k

 DateValidator validator = DateValidator.getInstance();
 java.util.Date utilDate= validator.validate(06-apr-07, dd-MMM-yy);
 java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());

Niall

On 6/22/06, Chris Cheshire [EMAIL PROTECTED] wrote:

try {
   java.sql.Date d = new java.sql.Date(new
SimpleDateFormat(dd-MMM-yy).parse(06-apr-07).getTime());
}
catch (ParseException ex) {
}

Chris

On 6/22/06, temp temp [EMAIL PROTECTED] wrote:
 I have a string which I want to convert into a date .
   The string   06-APR-07

   How can I convert this date into sql date ?

   Thanks




 -
 Yahoo! Groups gets better. Check out the new email design. Plus there's much 
more to come.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JAVA]Converting a string to date

2006-06-23 Thread Daoud Abdelmonem Faleh

I use this utility class:

package com.itCom.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
*
* @author Dao
*/
public class SQLDateConvertor {

   /** Creates a new instance of SQLDateConvertor */
   public SQLDateConvertor() {
   }
   public static String convertDateFormat(java.sql.Date date, String format)

   {
   DateFormat df = new SimpleDateFormat(format);

  try {
  return df.format(date);
  } catch (Exception exp) {
  return null;
  }

   }
   public static java.sql.Date convertToSqlDateFormat(String
value,String format) {

  DateFormat df = new SimpleDateFormat(format);

  try {

  Date date = df.parse(value);
  return new java.sql.Date(date.getTime());

  } catch (Exception exp) {
  return null;
  }
  }
}

On 6/23/06, Niall Pemberton [EMAIL PROTECTED] wrote:

Commons Validator 1.3.0 has a whole set of easy to use
validation/conversion routines:

  http://tinyurl.com/g526k

  DateValidator validator = DateValidator.getInstance();
  java.util.Date utilDate= validator.validate(06-apr-07, dd-MMM-yy);
  java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());

Niall

On 6/22/06, Chris Cheshire [EMAIL PROTECTED] wrote:
 try {
java.sql.Date d = new java.sql.Date(new
 SimpleDateFormat(dd-MMM-yy).parse(06-apr-07).getTime());
 }
 catch (ParseException ex) {
 }

 Chris

 On 6/22/06, temp temp [EMAIL PROTECTED] wrote:
  I have a string which I want to convert into a date .
The string   06-APR-07
 
How can I convert this date into sql date ?
 
Thanks
 
 
 
 
  -
  Yahoo! Groups gets better. Check out the new email design. Plus there's 
much more to come.
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JAVA]Converting a string to date

2006-06-23 Thread Madhav Bhargava

There are many ways you can do it:

One way is using Apache BeanUtils with Converters registered to it. This way
automatic conversions can happen
Again it depends on what date you want to convert- current date, arbitrary
date.

You can just go ahead and use SimpleDateFormat's format/parse methods.

On 6/23/06, Daoud Abdelmonem Faleh [EMAIL PROTECTED] wrote:


I use this utility class:

package com.itCom.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
*
* @author Dao
*/
public class SQLDateConvertor {

/** Creates a new instance of SQLDateConvertor */
public SQLDateConvertor() {
}
public static String convertDateFormat(java.sql.Date date, String
format)

{
DateFormat df = new SimpleDateFormat(format);

   try {
   return df.format(date);
   } catch (Exception exp) {
   return null;
   }

}
public static java.sql.Date convertToSqlDateFormat(String
value,String format) {

   DateFormat df = new SimpleDateFormat(format);

   try {

   Date date = df.parse(value);
   return new java.sql.Date(date.getTime());

   } catch (Exception exp) {
   return null;
   }
   }
}

On 6/23/06, Niall Pemberton [EMAIL PROTECTED] wrote:
 Commons Validator 1.3.0 has a whole set of easy to use
 validation/conversion routines:

   http://tinyurl.com/g526k

   DateValidator validator = DateValidator.getInstance();
   java.util.Date utilDate= validator.validate(06-apr-07, dd-MMM-yy);
   java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());

 Niall

 On 6/22/06, Chris Cheshire [EMAIL PROTECTED] wrote:
  try {
 java.sql.Date d = new java.sql.Date(new
  SimpleDateFormat(dd-MMM-yy).parse(06-apr-07).getTime());
  }
  catch (ParseException ex) {
  }
 
  Chris
 
  On 6/22/06, temp temp [EMAIL PROTECTED] wrote:
   I have a string which I want to convert into a date .
 The string   06-APR-07
  
 How can I convert this date into sql date ?
  
 Thanks
  
  
  
  
   -
   Yahoo! Groups gets better. Check out the new email design. Plus
there's much more to come.
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do


Re: [JAVA]Converting a string to date

2006-06-23 Thread Madhav Bhargava

For all these small things the best way is to google and find out. I am sure
you will get enough hits to suffice what you need.

On 6/24/06, Madhav Bhargava [EMAIL PROTECTED] wrote:


There are many ways you can do it:

One way is using Apache BeanUtils with Converters registered to it. This
way automatic conversions can happen
Again it depends on what date you want to convert- current date, arbitrary
date.

You can just go ahead and use SimpleDateFormat's format/parse methods.


On 6/23/06, Daoud Abdelmonem Faleh  [EMAIL PROTECTED] wrote:

 I use this utility class:

 package com.itCom.util ;

 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;

 /**
 *
 * @author Dao
 */
 public class SQLDateConvertor {

 /** Creates a new instance of SQLDateConvertor */
 public SQLDateConvertor() {
 }
 public static String convertDateFormat(java.sql.Date date, String
 format)

 {
 DateFormat df = new SimpleDateFormat(format);

try {
return df.format(date);
} catch (Exception exp) {
return null;
}

 }
 public static java.sql.Date convertToSqlDateFormat(String
 value,String format) {

DateFormat df = new SimpleDateFormat(format);

try {

Date date = df.parse(value);
return new java.sql.Date(date.getTime());

} catch (Exception exp) {
return null;
}
}
 }

 On 6/23/06, Niall Pemberton [EMAIL PROTECTED] wrote:
  Commons Validator 1.3.0 has a whole set of easy to use
  validation/conversion routines:
 
http://tinyurl.com/g526k
 
DateValidator validator = DateValidator.getInstance();
java.util.Date utilDate= validator.validate(06-apr-07,
 dd-MMM-yy);
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
 
  Niall
 
  On 6/22/06, Chris Cheshire [EMAIL PROTECTED] wrote:
   try {
  java.sql.Date d = new java.sql.Date(new
   SimpleDateFormat(dd-MMM-yy).parse(06-apr-07).getTime());
   }
   catch (ParseException ex) {
   }
  
   Chris
  
   On 6/22/06, temp temp [EMAIL PROTECTED] wrote:
I have a string which I want to convert into a date .
  The string   06-APR-07
   
  How can I convert this date into sql date ?
   
  Thanks
   
   
   
   
-
Yahoo! Groups gets better. Check out the new email design. Plus
 there's much more to come.
   
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




--
When I tell the truth, it is not for the sake of convincing those who do
not know it, but for the sake of defending those that do





--
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do


[JAVA]Converting a string to date

2006-06-22 Thread temp temp
I have a string which I want to convert into a date .
  The string   06-APR-07
  
  How can I convert this date into sql date ?
  
  Thanks
  
  
  

-
Yahoo! Groups gets better. Check out the new email design. Plus there’s much 
more to come.  

RE: [JAVA]Converting a string to date

2006-06-22 Thread Miller, Andy
For oracle:
to_date('06-APR-07', 'DD-MON-YY')

but this is more of a sql question than a struts question ;)

Andy Miller
IS Designer
Butte College
530.895.2946

-Original Message-
From: temp temp [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 22, 2006 10:25 AM
To: user@struts.apache.org
Subject: [JAVA]Converting a string to date

I have a string which I want to convert into a date .
  The string   06-APR-07
  
  How can I convert this date into sql date ?
  
  Thanks
  
  
  

-
Yahoo! Groups gets better. Check out the new email design. Plus there's
much more to come.  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JAVA]Converting a string to date

2006-06-22 Thread Chris Cheshire

try {
   java.sql.Date d = new java.sql.Date(new
SimpleDateFormat(dd-MMM-yy).parse(06-apr-07).getTime());
}
catch (ParseException ex) {
}

Chris

On 6/22/06, temp temp [EMAIL PROTECTED] wrote:

I have a string which I want to convert into a date .
  The string   06-APR-07

  How can I convert this date into sql date ?

  Thanks




-
Yahoo! Groups gets better. Check out the new email design. Plus there's much 
more to come.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]