Hello, I want the month and date in a 2-digit format. So am using NumberFormat. But this doesn't compile...can u pls help me out...or r there any way(s) out??? import java.text.*; import java.util.*; public class dt{ public static void main(String kk[]){ NumberFormat nf = new DecimalFormat("00"); Calendar rightNow = Calendar.getInstance(); int month= rightNow.get(Calendar.MONTH)+1; int day= nf.format(rightNow.get(Calendar.DAY_OF_MONTH)); System.out.println("Month is "+month); System.out.println("Date is "+day); } }
Thanks in advance, MSM
Mahesh Mamani
Ranch Hand
Joined: Jun 25, 2001
Posts: 110
posted
0
Originally posted by Mahesh Mamani: Hello, int month= rightNow.get(Calendar.MONTH)+1; int day= nf.format(rightNow.get(Calendar.DAY_OF_MONTH));
Got the prob, actually the prob was with the return type of NumberFormat.format(). Changed the code... MSM