-
-
Save sasajib/0447883497309c150bdd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Imports required | |
import java.text.SimpleDateFormat; | |
import java.text.ParseException; | |
/** | |
* Convert a date to a different format. | |
* | |
* @param currentFormat The current date format | |
* @param newFormat The new date format | |
* @param subject The date that's going to be converted | |
* @return The new data as a string | |
* @throws ParseException If the conversion fails (Invalid date format) | |
*/ | |
final public static String convertDate(String currentFormat, String newFormat, String subject) | |
throws ParseException | |
{ | |
return new SimpleDateFormat(newFormat).format( | |
new SimpleDateFormat(currentFormat).parse(subject) | |
).toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment