How to create a java.util.Date object from a date String?

How do I convert a String representation of a date in for the format dow mon dd hh:mm:ss zzz yyyy (e.g. "Mon Aug 27 17:12:59 EDT 2001") into a Date object? This you might note is the output of the Date classes toString() method. I don't want to have to parse this string. Thanks!

Try this out
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd");
String d = "19990831";
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(d));To create the SimpleDateFormat with a diffrent format check out all the possibilities here
http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
Hope this helps
Regards
Omer

Similar Messages

  • How can i compare:  java.util.Date oracle.jbo.domain.Date?

    I have made a ViewObject wich contains a date column.
    I want to check if this date is smaller/greater than sysdate:
    i get following error:
    Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
    code:
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);
    (VO_ULNRow)singleRow = null;
    while(vo.hasNext()){                                             // ViewObject vo;
    singleRow = (VO_ULNRow)vo.next();
    if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
    etcetera
    how can i compare those 2?

    Hi,
    oracle.jbo.domain.Date has two methods which suit your needs
    longValue() which returns a long (though I'm not sure if returns a long comparable to the long returned by java.util.Date)
    and dateValue() which returns a java.util.Date
    I hope it helps,
    Giovanni

  • How can I use java.util.Date and change display format.

    Hello All,
    I want to use java.util.Date in View Context and in Custom Control Context of Web dynpro java. When i mapped of a Input Field to the java.util.Date then message shows that its not supported. Plz suggest me how to handle Date with different formats ??

    If you always want the user to enter the date in dd/MM/yyyy, you can do the following.
    Goto Local Dictonary -> Simple types in your project and create a type known as "InputDate" (or whatever you feel) of built-in type 'Date'.
    Now specifiy its format in the 'Representation' tab as "dd/MM/yyyy" (case-senstive).
    Now declare a value attribute say "inputdate" in your context with this type and bind the inputfield to this context value attribute.
    This will solve your problem.
    But if you want the user to input date depending on the region he belongs, change the default locale date in Control Panel->Regional and Language Options->Change to English(UK) -> Customize -> Date Tab -> Sort Date Format to dd/MM/yyyy.
    Now clear the cache, delete temporary files and restart the machine. This should solve the problem.

  • How to create a java application & call it from a PDA via TELNET

    Dear All,
    My objective is to create a java application that's hosted on a server and called remotely from a PDA using TELNET.
    I've created a java application using Eclipse & the jCurses library. Unfortunately, the jCurses API events and listener aren't enough and i wasn't able to achieve my target application functionality.
    Can anyone advise a library other than jCurses that can help create a java application that can be called from a PDA via TELNET?
    Is AWT an option ?
    Thanks in advance for your support,
    Best regards,
    Lana

    user10827661 wrote:
    My objective is to create a java application that's hosted on a server and called remotely from a PDA using TELNET.
    I've created a java application using Eclipse & the jCurses library. Unfortunately, the jCurses API events and listener aren't enough and i wasn't able to achieve my target application functionality.
    Can anyone advise a library other than jCurses that can help create a java application that can be called from a PDA via TELNET?
    Is AWT an option ?Your server side Java application can use a Java library that
    creates a java.net.ServerSocket to listen for TCP connections from TELNET clients.
    You do not need any graphics (jCurses or AWT) on the server side, telnet is a simple ascii protocol.

  • How to create a universe in Business Object from BW

    Dear Memebers
    I need your help, I'm trying to create a report in business object using a cube as datasource, but when execute it does not appears the text, for example costumer 1000, his name is coca-cola.
    Does anyone help me?, maybe i does not set something
    Thanks a lot
    Ariel

    Hi Ariel,
    Not sure what BW is? If this is not related to using a SDK you may want to post your question in the Business Objects enterprise or Crystal Report Designer Forum.
    Thank you
    Don

  • (Again) java.util.Date vs java.sql.Date

    Hi there,
    (Again) Im trying to understand the EXACT difference between
    java.util.Date vs java.sql.Date.
    Googling, I can see that this is a very "popular" subject, but I still
    cannot figure out it exactly.
    Many writers claim that java.sql.Date only stores the DATE part (yyyy-
    mm-dd) but not the TIME part (hh:MM:ss) of a Date/Time value, but that
    I can easily disprove:
                    java.util.Date ud = new java.util.Date();                 java.sql.Date sd = new java.sql.Date(ud.getTime());                 System.out.println(DateFormatUtils.                                 format(ud, "yyyy-MM-dd HH:mm:ss.SSS"));                 System.out.println(DateFormatUtils.                                 format(sd, "yyyy-MM-dd HH:mm:ss.SSS"));
    Output:
                    2009-09-18 15:17:36.635                 2009-09-18 15:17:36.635
    So, apparently, java.sql.Date and java.util.Date have THE SAME
    precision (at least down to the millisecs...).
    And the official API documentation, really looks more confusing than
    helpful to me::
    *"java.sql.Date:*
    *A thin wrapper around a millisecond value that allows JDBC to identify*
    *this as an SQL DATE value. A milliseconds value represents the*
    *number of milliseconds that have passed since January 1, 1970*
    *00:00:00.000 GMT.*
    *To conform with the definition of SQL DATE, the millisecond values*
    *wrapped by a java.sql.Date instance must be 'normalized' by setting*
    *the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone with which the instance is associated. "*
    Exactly what means "an SQL DATE value" ? How EXACTLY does it differ
    from a java.util.Date value?
    Most importantly: WHY does JDBC need to distinguish between them?
    And, here again: *"a java.sql.Date instance must be 'normalized' by*
    *setting the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone..."*
    What does that mean exactly? Apparently, the constructor doesnt
    enforce this restriction, per the example above. So what's the REAL
    point with this type, java.sql.Date?
    Very greatful, if you can help me clarify this, once and for all.
    TIA,

    And the official API documentation, really looks more confusing than helpful to me:The problem is that you need to understand SQL as well as Java for this to make sense. It's not the Java API's job to tell you how your SQL database works - there's a myriad of subtle differences even when the DB is compliant with the SQL spec.
    Most compliant databases support DATE, TIME, and TIMESTAMP values. DATE represents only a date. TIME represents only a time. TIMESTAMP represents both. There are further complicating factors, but that's roughly how it stands.
    In Java the normal type for representing time is (or was when the API was created) the java.util.Date but this is a close approximation only to the TIMESTAMP value. In order to bring the two together the java.sql.Date, java.sql.Time and java.sql.Timestamp classes were created. Making them derive from java.util.Date was probably not a good idea.
    java.util.Date suffers from a number of deficiencies. java.util.Calendar was supposed to address them but didn't really succeed. The JodaTime library is rather better, but it's all a lot more complicated than you might expect - partly because time management really is a much harder problem than it appears at first glance - there are timezones, leap years, leap seconds, the difference between astronomical and atomic time, and so on and so forth.

  • Java.util.Date oracle.jbo.domain.Date how can i compare?

    I have made a ViewObject wich contains a date column.
    I want to check if this date is smaller/greater than sysdate:
    i get following error:
    Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
    code:
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);
    (VO_ULNRow)singleRow = null;
    while(vo.hasNext()){ // ViewObject vo;
    singleRow = (VO_ULNRow)vo.next();
    if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
    etcetera
    how can i compare those 2?

    i get following error:
    Error(45,24): method <(java.util.Date,
    oracle.jbo.domain.Date) not found in class Class4
    if(calendar.getTime() <
    singleRow.getEO_ULN_BORROWFROM()); //singleRow returns
    oracle.jbo.domain.Date
    how can i compare those 2? You cannot compare these two values directly. You must convert the oracle.jbo.domain.Date object to a GregorianCalendar object. Something like:
      oracle.jbo.domain.Date dt = singleRow.getEO_ULN_BORROWFROM();
      GregorianCalendar gc = new GregorianCalendar(dt.getYear(), dt.getMonth(), dt.getDay());
      if (calendar.getTime() < gc.getTime())
      }

  • Comparing java.util.Date objects...

    Hi,
    I got a problem using the follwing code:
    // get current date
    Date currentDate = new Date();
    // first check if column 'Date Actions Plan' has a valid value
    if (dl.getDate("actionsplanneddate", i) instanceof Date) {
    // then check if current date is after 'Date Actions Plan'
    if (currentDate.compareTo(dl.getDate("actionsplanneddate", i)) > 0) {
    I'd like to compare two Date objects - the first one is the current date and the second one is from a database column. The Date object of the database column has the following format (for example):
    2004-08-23 00:00:00
    The important thing is just the date (hours, minutes and seconds are not important in that case - therefore it is 00:00:00).
    I'd like to format the currentDate object in the same manner, which means setting hours, minutes and seconds to 00:00:00, too.
    Best regards
    - Stephan

    Hi,
    I got a problem using the follwing code:
    // get current date
    Date currentDate = new Date();
    // first check if column 'Date Actions Plan' has a
    valid value
    if (dl.getDate("actionsplanneddate", i) instanceof
    Date) {Why the instanceof? How would getDate not return a Date? (I'm assuming this is JDBC.)
    // then check if current date is after 'Date Actions
    Plan'
    if
    (currentDate.compareTo(dl.getDate("actionsplanneddate",
    i)) > 0) {
    I'd like to compare two Date objects - the first one
    is the current date and the second one is from a
    database column. The Date object of the database
    column has the following format (for example):If you have a java.util.Date or a java.sql.Date then it doesn't have format. It just represents an instant in time. Whatever format the DB uses or you used to create the date is not present in the Date object.
    You can use compareTo. I think Date also has before() and after() or isBefore()/isAfter() or something like that. Look at the API.
    Or you could call getTime() and compare the longs. Not sure why you'd want to do this though--I'm sure the other two idioms do this under the covers anyway.
    2004-08-23 00:00:00
    The important thing is just the date (hours, minutes
    and seconds are not important in that case - therefore
    it is 00:00:00).
    I'd like to format the currentDate object in the same
    manner, which means setting hours, minutes and seconds
    to 00:00:00, too.Ah. Well, then just creating a java.sql.Date from your java.util.Date might take care of that for you--I think the time portion is supposed to always be zero. Write some code and try it, but remember, it's GMT based, so you might see a nonzero time component, but it shoud match your TZ offset.
    Otherwise you'll have to use java.util.Calendar (java.util.GregorianCalendar)

  • How To Add Days into a Date from java.util.Date class

    I have a problem when i wants to add 2 or days into a
    date object geting by java.util.Date class. so please help me resolve this issue?
    for e.g i have a date object having 30/06/2001,
    by adding 2 days i want 02/07/2001 date object ?
    Code
    public class test2
    public static void main(String args[])
    java.util.Date postDate = new java.util.Date();
    myNewDate = postDate /* ?*/;
    Here i want to add 2 date into postDate

    Use Calendar...
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY"

  • How to change a date value from "java.util.Date" to "java.sql.Date"?

    Hi all,
    How to change a date value from "java.util.Date" to "java.sql.Date"?
    I m still confusing what's the difference between them.....
    thanks
    Regards,
    Kin

    Thanks
    but my sql statement can only accept the format (yyyy-MM-dd)
    such as "select * from xx where somedate = '2004-12-31'
    but when i show it to screen, i want to show it as dd-MM-yyyy
    I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
         public String date2str(java.util.Date thisdate)     {
              if (thisdate != null)     {
                   java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
                   return date2str(thissDate);
              }     else     {
                   return "";
         public String date2str(java.sql.Date thisdate)     {
              if (thisdate != null)     {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   return sdf.format(thisdate);
              }     else     {
                   return "";
         public java.util.Date str2date(String thisdate)     {
              String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
              java.util.Date returndate = null;
              if (thisdate != null)     {
                   SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
                   try {
                        returndate = dateFormatter.parse(thisdate);
                   } catch (ParseException pe) {
                        System.out.println (pe.getMessage());
              return returndate;
         }

  • How to insert java.util.Date to Oracle by OraclePrepaidStatement

    Hi all,
    I am trying to insert the date data to oracle a lot. But all of them works wrong???
    Here's a code:
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   java.sql.Date dd = new java.sql.Date(ud.getTime());
                   float ff = Integer.parseInt("1");
                   ps.setDate(1, dd);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();
              catch(Exception e)
                   e.printStackTrace();
    }Then I select from the table.
    select to_char(test.C_DATE, 'yyyy-MM-dd HH24:mi:ss')
    from test
    Its result is:
    2006-12-12 00:00:00
    I wanna to show 2006-12-12 17:33:01.
    How?

    Dear NiallMcG,
    Thank you very much, It now works fine.
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   float ff = Integer.parseInt("1");
                   Timestamp ts = new java.sql.Timestamp(ud.getTime());
                   ps.setTimestamp(1,ts);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();                    
              catch(Exception e)
                   e.printStackTrace();
              conn.release();
    }

  • Can not create WebService with java.util.Locale object why?

    I am unable to create a WebService which contains a Locale Object in the request.  I assume its because the java.util.Locale object is not Serializable.  Can anyone tell me if there is a work around for this?

    Hi,
    Make sure your strings for Locale follow these rules...
    The language string should be lower-case, two-letter codes as defined by ISO-639.
    http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
    The country string should be upper-case, two-letter codes as defined by ISO-3166.
    http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
    Or try with some constant Locales like
    Locale.CANADA
    Locale.US
    regards,
    Uma

  • Java.sql.Date vs java.util.Date vs. java.util.Calendar

    All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
    I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
    Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
    Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
    One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
    Example:
    public class Date extends java.sql.Date implements RangedColumn {
      public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
      public static final String TYPE = "DATE";
       * Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
       * limitation. Java allows dates from '0000-01-01' while MySQL only supports
       * dates from '1000-01-01'.
      public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
       * Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
       * limitation. MySQL allows dates up to '9999-12-31' while Java only supports
       * dates to '8099-12-31'.
      public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
      protected int _precision = 0;
      private java.sql.Date _date = null;
      public Date(int year, int month, int date) {
        // Deprecated, so I get deprecation warnings from the next line:
        super(year,month,date);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public Date(String s) {
        super(0l);
        // Start Cut-and-paste from java.sql.Date.valueOf(String s)
        int year;
        int month;
        int day;
        int firstDash;
        int secondDash;
        if (s == null) throw new java.lang.IllegalArgumentException();
        firstDash = s.indexOf('-');
        secondDash = s.indexOf('-', firstDash+1);
        if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
          year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
          month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
          day = Integer.parseInt(s.substring(secondDash+1));
        } else {
          throw new java.lang.IllegalArgumentException();
        // End Cut-and-paste from java.sql.Date.valueOf(String s)
        // Next three lines are deprecated, causing warnings.
        this.setYear(year);
        this.setMonth(month);
        this.setDate(day);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public static boolean isWithinRange(Date date) {
        if(date.before(MIN_DATE))
          return false;
        if(date.after(MAX_DATE))
          return false;
        return true;
      public String getRange() { return RANGE; }
      public int getPrecision() { return _precision; }
      public String getType() { return TYPE; }
    }This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
    So at this point, I am at a loss.
    The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
    I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
    To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
    So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
    That's all I really want.
    HELP!

    I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
    If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
    -G

  • Wsimport, mapping of xs:date to java.util.Date via ext file, and -B option

    Summary:
    JDK 1.7.0_09 and wsimport and xjc that comes with it.
    Global JAXB binding to map xs:date to java.util.Date
    I have the following external bindings file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
         elementFormDefault="qualified" attributeFormDefault="unqualified"
         jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
         <xs:annotation>
              <xs:appinfo>
                   <jaxb:globalBindings>
                        <xjc:serializable />
                        <jaxb:javaType name="java.util.Date" xmlType="xs:date" parseMethod="au.com.xxx.jaxb.DateAdapter.parseDate" printMethod="au.com.xxx.jaxb.DateAdapter.printDate" />
                   </jaxb:globalBindings>
              </xs:appinfo>
         </xs:annotation>
    </xs:schema>The au.com.xxx.jaxb.DateAdapter code is as follows:
    package au.com.xxx.jaxb;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import javax.xml.bind.DatatypeConverter;
    public class DateAdapter {
         public static Date parseDate(String s) {
              return DatatypeConverter.parseDate(s).getTime();
         public static String printDate(Date dt) {
              Calendar cal = new GregorianCalendar();
              cal.setTime(dt);
              return DatatypeConverter.printDate(cal);
    }When I run the following wsimport from the command line, I get:
    salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
    $ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
    parsing WSDL...
    Generating code...
    Compiling code...
    C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:13: error: package au.com.xxx.jaxb does not exist
            return (au.com.xxx.jaxb.DateAdapter.parseDate(value));
                                   ^
    C:\workspace\JSF\insurance\gen-src\org\w3\_2001\xmlschema\Adapter1.java:17: error: package au.com.xxx.jaxb does not exist
            return (au.com.xxx.jaxb.DateAdapter.printDate(value));
                                   ^
    2 errors
    compilation failed, errors should have been reportedWhich means that wsimport or xjc needs to know the classpath to find au.com.xxx.jaxb.DateAdapter.
    But how do I pass the classpath from wsimport to the JAXB compiler ?
    There is the -B option in wsimport, but I could not get it to work.
    If I read it correctly, I should be able to pass the -classpath option to the JAXB compiler from wsimport via -B.
    I tried:
    salvojo@AUD20901BL /cygdrive/c/workspace/JSF/insurance
    $ /cygdrive/c/java/jdk1.7.0_09/x64/bin/wsimport -keep -s gen-src -B"-classpath WebContent/WEB-INF/classes" -b external/wsdl/jaxb-bindings.xml -wsdllocation /wsdl/Member.wsdl -d WebContent/WEB-INF/classes external/wsdl/Member.wsdl
    no such JAXB option: -classpath WebContent/WEB-INF/classes
    Usage: wsimport [options] <WSDL_URI>
    where [options] include:
      -b <path>                 specify jaxws/jaxb binding files or additional schemas
                                (Each <path> must have its own -b)
      -B<jaxbOption>            Pass this option to JAXB schema compiler
      -catalog <file>           specify catalog file to resolve external entity references
                                supports TR9401, XCatalog, and OASIS XML Catalog format.
      -d <directory>            specify where to place generated output files
    <...snipped...>... where WebContent/WEB-INF/classes is the classpath where au.com.xxx.jaxb.DateAdapter.class could be found. Obviously it did not like it.
    Also, why is wsimport generate org.w3._2001.xmlschema.Adapter1.java ? All it is doing is wrapping up the exact same call that I have specified in my DateAdapter. How can I tell wsimport or xjc to NOT create that extra Adapter1.java and simply directly use my DateAdapter ??

    create additional column of type LONG to represent date.
    dateFormat is of type java.util.Date:
    long newLongDate = dateFormat.getTime();
    select object(b) from MyEntity b where b.MYLONGDATE > ?1 and b.MYLOGDATE <= ?2

  • How to create a JComboBox with Dates???

    Hi... I need to create a JComboBox with Date elements...
    For example: from "Jan-01-2007" to "Mar-02-2007"
    Jan-01-2007
    Jan-02-2007
    Jan-03-2007
    Mar-01-2007
    Mar-02-2007
    Anyone know how to do it???
    Regards...

    //here is an example how to get the date
    //I think this might help you!!!
    import java.text.DateFormat;
    import java.util.Date;
    public class DateFormatExample1 {
        public static void main(String[] args) {
            // Make a new Date object. It will be initialized to the current time.
            Date now = new Date();
            // See what toString() returns
            System.out.println(" 1. " + now.toString());
            // Next, try the default DateFormat
            System.out.println(" 2. " + DateFormat.getInstance().format(now));
            // And the default time and date-time DateFormats
            System.out.println(" 3. " + DateFormat.getTimeInstance().format(now));
            System.out.println(" 4. " +
                DateFormat.getDateTimeInstance().format(now));
            // Next, try the short, medium and long variants of the
            // default time format
            System.out.println(" 5. " +
                DateFormat.getTimeInstance(DateFormat.SHORT).format(now));
            System.out.println(" 6. " +
                DateFormat.getTimeInstance(DateFormat.MEDIUM).format(now));
            System.out.println(" 7. " +
                DateFormat.getTimeInstance(DateFormat.LONG).format(now));
            // For the default date-time format, the length of both the
            // date and time elements can be specified. Here are some examples:
            System.out.println(" 8. " + DateFormat.getDateTimeInstance(
                DateFormat.SHORT, DateFormat.SHORT).format(now));
            System.out.println(" 9. " + DateFormat.getDateTimeInstance(
                DateFormat.MEDIUM, DateFormat.SHORT).format(now));
            System.out.println("10. " + DateFormat.getDateTimeInstance(
                DateFormat.LONG, DateFormat.LONG).format(now));
    }

Maybe you are looking for