Online Java Compiler By
JavaTpoint.com
import java.util.Date; public class JavaDateSetDateExample1 { public static void main(String[] args) { Date d=new Date(); System.out.println("Old date is : "+d.getDate()); d.setDate(10); System.out.println("Date after setting is : "+d.getDate()); } }
Output