Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

return day from date in java

 /*
     * 'findDay' function
     *
     * The function is expected to return a STRING.
     * The function accepts following parameters:
     *  1. INTEGER month
     *  2. INTEGER day
     *  3. INTEGER year
     */

public static String findDay(int month, int day, int year) {
        SimpleDateFormat simpleDateformat = new SimpleDateFormat("EEEE");
        
        Date date = new GregorianCalendar(year, month - 1, day).getTime();
        String dayText = simpleDateformat.format(date);
    
        return dayText.toUpperCase(); 
}
Comment

java get year month day hour minute second

LocalDateTime now = LocalDateTime.now();
int year = now.getYear();
int month = now.getMonthValue();
int day = now.getDayOfMonth();
int hour = now.getHour();
int minute = now.getMinute();
int second = now.getSecond();
int millis = now.get(ChronoField.MILLI_OF_SECOND); // Note: no direct getter available.

System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis);
Comment

get year month day from date string java

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");  
Date parse = sdf.parse("18/08/2012");  
Calendar c = Calendar.getInstance();  
c.setTime(parse);  
System.out.println(c.get(Calendar.MONTH) + c.get(Calendar.DATE) + c.get(Calendar.YEAR));
Comment

get day from date month year java

Calendar cal = Calendar.getInstance();
cal.set(year,month-1,day);
int nd = cal.get(Calendar.DAY_OF_WEEK);
Comment

get last day of month java

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
Date lastDayOfMonth = cal.getTime();
Comment

PREVIOUS NEXT
Code Example
Java :: spring boot jackson infinite recursion 
Java :: factors 
Java :: min max heap java 
Java :: primitive data types in java 
Java :: java get relative path 
Java :: arraylist to array java 
Java :: android java listview clean 
Java :: spring maven plugin 
Java :: java stream get all max values 
Java :: find minimum in array java 
Java :: AndroidManifest.xml could not be found. 
Java :: hello world! java 
Java :: can interface have attributes java 
Java :: string format java 
Java :: spring websocket allow origin 
Java :: how to create localdate object in java 
Java :: java loop using input user 
Java :: java instance of a class 
Java :: space seperator in string in java 
Java :: final finally finalize 
Java :: reverse a string in java 
Java :: how to give square in java 
Java :: how to substring in java 
Java :: how to update java runtime 
Java :: character types java 
Java :: arraylist to linkedlist java 
Java :: how to run java files 
Java :: java date and time 
Java :: Program to remove duplicates in an ArrayList 
Java :: java http response code 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =