Last active
March 19, 2020 12:01
-
-
Save bmnepali/dda28c1c4844a6598632e86f8fd66386 to your computer and use it in GitHub Desktop.
Get full fay name from given date
This file contains 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
public class GetDayFromDate { | |
public static void main(String[] args) { | |
Date now = new Date(); | |
SimpleDateFormat simpleDateformat = new SimpleDateFormat("E"); // the day of the week abbreviated | |
System.out.println(simpleDateformat.format(now)); | |
simpleDateformat = new SimpleDateFormat("EEEE"); // the day of the week spelled out completely | |
System.out.println(simpleDateformat.format(now)); | |
Calendar calendar = Calendar.getInstance(); | |
calendar.setTime(now); | |
System.out.println(calendar.get(Calendar.DAY_OF_WEEK)); // the day of the week in numerical format | |
} | |
} | |
// Output | |
// Wed | |
// Wednesday | |
// 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment