public static void main(String[] args)
{
String sDate = "30.06.2001";
System.out.println( sDate);
SimpleDateFormat localFormatter = new SimpleDateFormat("MM.dd.yyyy");
ParsePosition pos = new ParsePosition(0);
Date myDate = localFormatter.parse(sDate, pos);
System.out.println( localFormatter.format(myDate) );
}
}
It produces the following outup :
30.06.2001
06.06.2003
Any explanation is welcomed.
--
Jean-Philippe Forti
EIM SA Switzerland jpforti@eim.nospam (replace nospam with ch)
04-18-2001, 03:16 PM
Paul Clapham
Re: Java and dates ?
The 6th day of the 30th month of 2001: that's two years later than the 6th
day of the 6th month of 2001.
PC2
"Jean-Philippe Forti" <jpforti@eim.nospam> wrote in message
news:3adda47d$1@news.devx.com...
> Could someone tell me why java convert the following date 30.06.2001
> (MM.DD.YYYY) in 06.06.2003 ?
>
> I use the followin code :
>
> import java.util.Date;
> import java.util.Calendar;
> import java.text.SimpleDateFormat;
> import java.text.ParsePosition;
>
> public class DateTest
> {
>
> public DateTest()
> {
> }
>
> public static void main(String[] args)
> {
> String sDate = "30.06.2001";
> System.out.println( sDate);
> SimpleDateFormat localFormatter = new SimpleDateFormat("MM.dd.yyyy");
> ParsePosition pos = new ParsePosition(0);
> Date myDate = localFormatter.parse(sDate, pos);
> System.out.println( localFormatter.format(myDate) );
> }
> }
>
> It produces the following outup :
> 30.06.2001
> 06.06.2003
>
>
> Any explanation is welcomed.
>
>
> --
> Jean-Philippe Forti
> EIM SA Switzerland
> jpforti@eim.nospam (replace nospam with ch)
>
>
04-19-2001, 03:02 AM
Jean-Philippe Forti
Re: Java and dates ?
So ???
How could I avoid it ?
"Paul Clapham" <pclapham@core-mark.com> wrote in message
news:3adde707$1@news.devx.com...
> The 6th day of the 30th month of 2001: that's two years later than the
6th
> day of the 6th month of 2001.
>
> PC2
>
> "Jean-Philippe Forti" <jpforti@eim.nospam> wrote in message
> news:3adda47d$1@news.devx.com...
> > Could someone tell me why java convert the following date 30.06.2001
> > (MM.DD.YYYY) in 06.06.2003 ?
> >
> > I use the followin code :
> >
> > import java.util.Date;
> > import java.util.Calendar;
> > import java.text.SimpleDateFormat;
> > import java.text.ParsePosition;
> >
> > public class DateTest
> > {
> >
> > public DateTest()
> > {
> > }
> >
> > public static void main(String[] args)
> > {
> > String sDate = "30.06.2001";
> > System.out.println( sDate);
> > SimpleDateFormat localFormatter = new
SimpleDateFormat("MM.dd.yyyy");
> > ParsePosition pos = new ParsePosition(0);
> > Date myDate = localFormatter.parse(sDate, pos);
> > System.out.println( localFormatter.format(myDate) );
> > }
> > }
> >
> > It produces the following outup :
> > 30.06.2001
> > 06.06.2003
> >
> >
> > Any explanation is welcomed.
> >
> >
> > --
> > Jean-Philippe Forti
> > EIM SA Switzerland
> > jpforti@eim.nospam (replace nospam with ch)
> >
> >
>
>
04-19-2001, 10:52 AM
Paul Clapham
Re: Java and dates ?
Avoid what? The only other option you have is to make it throw an
exception. And you would do that by
localFormatter.setLenient(false);
PC2
"Jean-Philippe Forti" <jpforti@eim.nospam> wrote in message
news:3ade8ce9$1@news.devx.com...
> So ???
> How could I avoid it ?
>
>
> "Paul Clapham" <pclapham@core-mark.com> wrote in message
> news:3adde707$1@news.devx.com...
> > The 6th day of the 30th month of 2001: that's two years later than the
> 6th
> > day of the 6th month of 2001.
> >
> > PC2
> >