Sure ... I don't mind posting the code. See below:
public void convert() {
String conv_dt = null;
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
int dayOfYear = 0;
String yr = null;
try {
Date dt = df.parse(datefield.getText());
Calendar c = df.getCalendar();
c.setTime(dt);
c.setLenient(false);
dayOfYear = c.get(Calendar.DAY_OF_YEAR);
SimpleDateFormat sdf = new SimpleDateFormat("yy");
yr = sdf.format(dt);
}
catch (ParseException pe) {
converted_date.setText(pe.getMessage());
}
if (dayOfYear < 100)
converted_date.setText("00" + Integer.toString(dayOfYear) + yr);
else
converted_date.setText("0" + Integer.toString(dayOfYear) + yr);
}
I see what you are saying about the
doc in Date. I read that too, but I'm concerned about the user putting in a wrong date liked 1/32/00 and NOT meaning 2/1/00. If it works this way, how do I know if it's calculating a leap year?