[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-user
Subject:    Re: [SPAM] - Can I create date with jakarta commons - Email has different SMTP TO: and MIME TO: fiel
From:       "Chris Cheshire" <cheshirator () gmail ! com>
Date:       2006-10-24 21:33:07
Message-ID: bdb002250610241433k183be63fy649f40fdbf271928 () mail ! gmail ! com
[Download RAW message or body]

Use a java.text.SimpleDateFormat.

Date d = new SimpleDateFormat("yyyyMMdd").parse("20061225", new
ParsePosition(0));

If you use a format a lot, create a static instance of the
SimpleDateFormat and just reference parse() on that object as needed.

HTH

Chris

On 10/6/06, baranovsky@liga.net <baranovsky@liga.net> wrote:
> Hmm...
>
> But I need create java.util.Date object with concrete Date. Can I do this
> using one row of code? Is there something like createDate(2006, 11, 25)
> that returns java.util.Date?
>
> Julius Davies <juliusdavies@cucbc.com> wrote on 07.10.2006 03:47:42:
>
> > Hi, Vitaly,
> >
> > Try java.util.GregorianCalendar!
> >
> > // Christmas is December 25th.
> > Calendar c = new GregorianCalendar( 2006, 11, 25 );
> >
> > // 1 second after this coming New Years:
> > int year = 2007;
> > int month = 0; // January is 0
> > int dayOfMonth = 1;
> > int hourOfDay = 0;
> > int minute = 0;
> > int second = 1;
> > c = new GregorianCalendar( year, month, dayOfMonth, hourOfDay,
> > minute, second );
> >
> >
> > yours,
> >
> > Julius
> >
> > http://juliusdavies.ca/
> >
> >
> > On Sat, 2006-07-10 at 02:58 +0300, baranovsky@liga.net wrote:
> > > Good day!
> > >
> > > I need sometimes to create concrete Date object. I have the function to
> do
> > > it now:
> > >
> > >       public static Date createDate(int year, int month, int day){
> > >             Calendar calendar = Calendar.getInstance();
> > >
> > >             calendar.set(year, month, day, 0, 0, 0);
> > >             calendar.set(Calendar.MILLISECOND, 0);
> > >
> > >             return calendar.getTime();
> > >       }
> > >
> > > Is there such function in commons?
> > >
> > > Thanks!
> > >
> > > _____________
> > > With best regards,
> > > Vitaly Baranovsky
> > >
> > >

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic