plz plz help (URGENTLY REQUIRED)
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kumar_john
Posted On:   Friday, November 16, 2007 11:57 AM

I HAV PROBLEM ON SimpleDateFormat. in following code:- import java.sql.*; import java.text.*; public class test { public static void main(String args[])throws Exception { java.util.Date d1= new java.util.Date(); System.out.println(d1); String z="16/11/2007"; SimpleDateFormat sd2= new SimpleDateFormat("dd/mm/yyyy"); java.util.Date d3=null; try{ d3=sd2.parse(z); System.out.println(d3); }catch(Exception e){System.out.println(e); } System.out.   More>>

I HAV PROBLEM ON SimpleDateFormat.
in following code:-



import java.sql.*;

import java.text.*;

public class test



{


public static void main(String args[])throws Exception


{


java.util.Date d1= new java.util.Date();


System.out.println(d1);


String z="16/11/2007";


SimpleDateFormat sd2= new SimpleDateFormat("dd/mm/yyyy");



java.util.Date d3=null;


try{


d3=sd2.parse(z);


System.out.println(d3);


}catch(Exception e){System.out.println(e);


}

System.out.println(d3.getDay());

}



}
}


when i run this code

it return the month of d3 as jan


what ever value i gave it always return jan

how can i solve the problem.


Actually i want to retrive the day from a date value.
plz help...

   <<Less

Re: plz plz help (URGENTLY REQUIRED)

Posted By:   Anonymous  
Posted On:   Thursday, January 24, 2008 06:45 PM

Java lets you define your own format. The only restriction is that you need to adhere to the case and style of the individual character or literal used to represent the date part. Following are some of the commonly used symbols in date formatting.


i.e.
y : Year
M : Month
d : Day in a Month
D : Day in Year
E : Day in Week
G : Century (e.g AD)
a : AM/PM
z : Time zone (CST etc)
Z : Time difference from GMT
H : Hour (0-23)
h : Hour in am/pm (1-12)
m : Minute
s : Second
S : Millisecond


Hope this helps!


Sincerely,

your friends at JavaAdvice.com

http://www.JavaAdvice.com - The one stop resource for all your Java questions and answers
...........................................

see mr ---------------

Posted By:   Anonymous  
Posted On:   Monday, December 3, 2007 04:37 AM

import java.sql.*;
import java.text.*;
public class Test
{
public static void main(String args[])throws Exception
{
java.util.Date d1= new java.util.Date();
System.out.println(d1);

String z="4/20/2007";
SimpleDateFormat sd2= new SimpleDateFormat("M/d/yy");
java.util.Date d3=null;
try
{
d3=sd2.parse(z);
System.out.println(d3);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println(d3.getDay());
}
}

Re: plz plz help (URGENTLY REQUIRED)

Posted By:   Anonymous  
Posted On:   Wednesday, November 28, 2007 07:27 AM

The d3.getDay() has been depricated thtswhy it is showing the Jan.




Thanks & Regards

Jyoti Biaksh Panda
Motherson Sumi Infotech & Designs Ltd.
Noida
jyoti.panda@mind-infotech.com

Re: plz plz help (URGENTLY REQUIRED)

Posted By:   Robert_Lybarger  
Posted On:   Friday, November 16, 2007 08:09 PM

Lowercase "m" in format pattern means "minutes". You probably meant uppercase "M" for "month". In effect, you built a pattern such that "z" parsed to january 16 207 at 11 minutes past midnight.
About | Sitemap | Contact