get month Day string as MMdd - Java java.util

Java examples for java.util:Month

Description

get month Day string as MMdd

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(monthDay());
    }/*from   w ww.  j  av a  2s .com*/

    public static String monthDay() {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
        return sdf.format(cal.getTime());

    }
}

Related Tutorials