HI All,

can any one help me how to convert customize date formats like these below
"JAN FY2010" "Q1 FY2010"

DateFormat df = new SimpleDateFormat("?")

as i couldnt find any matching date formats to these.
Appreciate your help!!!!!

Can you give a sample date that would format to what you want?
I don't know about the Q1 but the JAN should be possible.
What have you tried with the SimpleDateFormat for "JAN FY2010"?

Edited 6 Years Ago by NormR1: n/a

Hi NormR1,

Thanks you for your response!!!
actually i have a list of objects from DB with the same format mentioned above.
like ""JAN FY2010" (January Fiscal Year 2010) and "Q1 FY2010" (Quarter one FY2010)
I can customize Date format with the following code, if FY is not in the format.
Date date = new SimpleDateFormat("MMM yyyy")//whithout FY string.(i.e JAN 2010)
my Question here is there any way where i can include my own string(FY) in the date format(JAN 2010).
my task here is i have DB values("JAN FY2010","FEB FY2010","MAR FY2010"......"JAN FY2006")in the table.but i need to display only from "JAN FY2010" to "OCT FY2010" in jsp dropdown.
this is what i am trying.sample code which i cannot compile as the format is wrong..

public static void main(String args[]) throws Exception{
       DAO dao = new DAO();
       DateFormat df = new SimpleDateFormat("MMM yyyy");//this format is wrong as my date would be JAN FY2010
       ArrayList newList = new ArrayList();

        try
        {
            List weekDD = dao.getTimePeriodDD();
            for(int i = 0;i<weekDD.size();i++){ 
                String week = (String)weekDD.get(i);
                Date weekDate = df.parse(week); 
                Date cutOffDate = df.parse("JAN FY2010"); 
                if(weekDate.after(cutOffDate))  { 
                  newList.add(week); 
                }
            }
            for(int i = 0;i<newList.size();i++){
                String data = (String)newList.get(i);
                System.out.println("dates after JAN FY2010:"+ data);
            }

        }

Need some pointers.....

need to display only from "JAN FY2010"

Use:
SimpleDateFormat("MMM 'FY'yyyy")
to format the date.

Hi NormR1,

Thanx!!!!!!!!! a simple sol...
it worked...

Hey NormR1,

one more Question,
i have these formats like Q1 FY2010,Q2 FY2010,Q3 FY2010,Q4 FY2010,Q1 FY2019,Q2 FY2010 and so on
how to format them??
Thanks for your help.........

This article has been dead for over six months. Start a new discussion instead.