I have created a simple example where one can get the last month first day of month by creating a class by extending a simple java class and then creating own function.
package com.date.extension;
/**
*
* @author Ajay
* This example shows how we can create the extension of the existing java API classes to
* create our own custom class.
* These days all the new tools those are build using the java API are using these concepts
*
*/
public class DateExtension extends java.util.Date{
/**
*
*/
private static final long serialVersionUID = -6611137942020737569L;
public DateExtension(){
}
@Deprecated
public java.util.Date getPriorMonth() {
this.setDate(1);
this.setMonth(this.getMonth()-1);
return this;
}
}
No comments:
Post a Comment