S
SN
hi
I need to control the precision of date display i.e. conditionally
include year info or month info etc.
Something like the following function - the catch is that the
dateFormat is already an input to this method - the dateFormat is
derived from user preferences - but user preferences only allow the
user to choose the appearance of the date viz. mm/dd/yy or dd/mm/yy or
dd-mm-yyyy etc.
What components of date to show (i.e. the date precision - hours, day,
month) is decided by program logic
Can I chop off components from a given DateFormat in a generic way?
i.e. i want a way to say "use this date format but don't include year
information"
String getDateDisplayString(SimpleDateFormat df, java.util.Date d, int
precision)
{
switch(precision)
{
case 1: //return string with only month and year
case 2: //return string with only day and month
case 3: //return string with only day, hour and am/pm
}
//df.format(d) will always spit out all the components of the date
}
thanks
sn
I need to control the precision of date display i.e. conditionally
include year info or month info etc.
Something like the following function - the catch is that the
dateFormat is already an input to this method - the dateFormat is
derived from user preferences - but user preferences only allow the
user to choose the appearance of the date viz. mm/dd/yy or dd/mm/yy or
dd-mm-yyyy etc.
What components of date to show (i.e. the date precision - hours, day,
month) is decided by program logic
Can I chop off components from a given DateFormat in a generic way?
i.e. i want a way to say "use this date format but don't include year
information"
String getDateDisplayString(SimpleDateFormat df, java.util.Date d, int
precision)
{
switch(precision)
{
case 1: //return string with only month and year
case 2: //return string with only day and month
case 3: //return string with only day, hour and am/pm
}
//df.format(d) will always spit out all the components of the date
}
thanks
sn