Get current Day,Month,Year separately in android.

Try this:-
/**
 * Get Current day,month,year according
 * format like Never,Daily,Yearly,Monthly.
 *
 * @param format
 * @return current day,month,year
 */
public static String get_Current_Day_Month_Yearly(String format) {
    Log.e("Check", "get_Current_Day_Month_Yearly:- ");
    Calendar c = Calendar.getInstance();

    if (format.contains("Never")) {
        return "";
    } else if (format.contains("Daily")) {
        Log.e("Check", "get_Current_Day_Month_Yearly:- " + "Daily");
        Log.e("Check", "day:- " + c.get(Calendar.DAY_OF_MONTH));
        return String.valueOf(c.get(Calendar.DAY_OF_MONTH));///10 SEp,   11 Sep:   100

    } else if (format.contains("Monthly")) {
        return String.valueOf(c.get(Calendar.MONTH) + 1);

    } else if (format.contains("Yearly")) {
        return String.valueOf(c.get(Calendar.YEAR));

    }

    return "";

}
get_Current_Day_Month_Yearly("Daily")
Output:- 11
get_Current_Day_Month_Yearly("Monthly")
Output:- 11
get_Current_Day_Month_Yearly("Yearly")
Output:- 2019

Search by:-

how to get month and year from string date in java

java get current month

java get current year

get year from calendar java

java get year from date

get day from calendar java

simpledateformat

localdate java get day

java date format

get only month and year from date in java

how to get day from date in java

how to get day from date in java using calendar

how to get day name from date in java

java calendar get day of week string

java program to find the day of a given date

getday in java

android get day of week from date

java calendar day of week

java date and time hackerrank solution

java calendar day of week

how to get day name from date in java

how to get day from date in java using calendar

java program to find the day of a given date

android get day of week from date

day of the week java program

get day of week from timestamp java

calendar get weekday java

java calendar get day of week string

how to get day name from date in java

java get day of week from date string

java calendar day of week

write a function solution that given a string s representing the day of the week and an integer k

get day from calendar java

android get day of week from date

write a program to print the day of the week in java using if else

how to get day name from date in java 8

java calendar get day of week string

android get day of week from date

java program to find the day of a given date

getday method in java

calendar get weekday java

java date and time hackerrank

how to convert date into days in java





Comments

Popular posts from this blog

Error:java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:240) at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215) at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:143) at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:78) at com.google.android.material.chip.ChipDrawable.loadFromAttributes(ChipDrawable.java:359) at com.google.android.material.chip.ChipDrawable.createFromAttributes(ChipDrawable.java:292) at com.google.android.material.chip.Chip.(Chip.java:193) at com.google.android.material.chip.Chip.(Chip.java:186) at com.google.android.material.chip.Chip.(Chip.java:182) at com.demo.nspl.restaurantlite.Navigation_Drawer.SalesFragment.getFilterChip(SalesFragment.java:158) at com.demo.nspl.restaurantlite.Navigation_Drawer.SalesFragment.lambda$onCreateView$0(SalesFragment.java:71) at com.demo.nspl.restaurantlite.Navigation_Drawer.-$$Lambda$SalesFragment$KCm-iiczjdYbpiNmaNw12gtFOoQ.onClick(lambda) at android.view.View.performClick(View.java:5268) at android.view.View$PerformClick.run(View.java:21550) at android.os.Handler.handleCallback(Handler.java:822) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5811) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)

Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation' and 'androidTestApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html