Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

How can I create a date and calculate the days of the week?

 

The current day can be obtained as a date variable with Date.

Date dtRow= new Date();

 

Format Date

A Date field can be output as string using the string formatting SimpleDateFormat

SimpleDateFormat fmtWeekday = new SimpleDateFormat("EE");
String weekday = fmtWeekday.format(dtRow);

 

If you want to be more complex with date, then you have to use the calendar.

To do this, create a calendar with Calendar.getInstance () and then assign a date to this calendar date.

If the date is assigned in the calendar, you can easily use Calendar.get (..) get the individual information about the calendar date.

//*as weekday_number
Calendar calendarDay=Calendar.getInstance();
calendarDay.setTime(dtRow);
int NrWeekday=calendarDay.get(Calendar.DAY_OF_WEEK);//  fmtWeekdayNr.format(dtRow);

 

 

 

Code example from the Android year calendar project, school calendar

//-< Date >-
Date dtRow= clsHelper.getDate(2018,9,iDay);
//< weekday >
//*as string
SimpleDateFormat fmtWeekday = new SimpleDateFormat("EE");
String weekday = fmtWeekday.format(dtRow);
//</ weekday >

//*as weekday_number
Calendar calendarDay=Calendar.getInstance();
calendarDay.setTime(dtRow);
int NrWeekday=calendarDay.get(Calendar.DAY_OF_WEEK);//  fmtWeekdayNr.format(dtRow);
//-</ Date >-

 

Mobile
»
Android Java: Read text from a resource file
»
Android Java: Create unique GUID at runtime
»
Android Java: Comparison with empty string
»
Android java: Code area // region - // endregion
»
Android: Create a color picker
»
Android: View items by name or tag or id
»
Android Java: Create a view event at runtime and assign it to a view element
»
Android Java: Create view button at runtime
»
Android Java: create a view element as a float
»
Input field in Android

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de