Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SimpleDateFormat display 3 digit year, help!

807589Jan 8 2009 — edited Jan 8 2009
Hi, I am from Taiwan (ROC).
2009 in our country year must minus 1911 and become 98.
2 years later (2011), our country year becomes 100.
"2009.01.08" I want to display "098.01.08" so I use the format "yyy.MM.dd"
but the result is "98.01.08".

If discare DAY_OF_WEEK problem.

Below is my code.
import java.text.SimpleDateFormat;
import java.util.Calendar;

class SimpleROCDateFormat extends SimpleDateFormat
{
  SimpleROCDateFormat(String ptn)
  {
    super(ptn);
  }
  
  public String format(Calendar cal)
  {
    Calendar calendar = (Calendar)cal.clone();
    calendar.add(Calendar.YEAR,-1911);
    return super.format(calendar.getTime());
  }
}
import java.util.*;

class test
{
  public static void main(String args[])
  {
   Calendar now = Calendar.getInstance();
   SimpleROCDateFormat sROCdf = new SimpleROCDateFormat("yyy.MM.dd");
   String ROCnow = sROCdf.format(now);
   System.out.println(ROCnow);
  }
}
Wish your help. Thank you!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2009
Added on Jan 8 2009
14 comments
1,286 views