Package hirondelle.date4j

Examples of hirondelle.date4j.DateTime.format()


    /**
     * What is the current date-time in the JRE's default time zone?
     */
    public static void currentDateTime () {
        DateTime now = DateTime.now( TimeZone.getDefault() );
        String result = now.format( "YYYY-MM-DD hh:mm:ss" );
        log( "Current date-time in default time zone : " + result );
    }

    /**
     * What is the current date-time in Cairo (include weekday)?
View Full Code Here


    /**
     * What is the current date-time in Cairo (include weekday)?
     */
    public static void currentDateTimeInCairo () {
        DateTime now = DateTime.now( TimeZone.getTimeZone( "Africa/Cairo" ) );
        String result = now.format( "YYYY-MM-DD hh:mm:ss (WWWW)", Locale.getDefault() );
        log( "Current date-time in Cairo : " + result );
    }

    /**
     * What's the age of someone born May 16, 1995?
View Full Code Here

            result = 21;
        } else {
            result = 21 - firstOfMonth.getWeekDay();
        }
        DateTime thirdFriday = DateTime.forDateOnly( firstOfMonth.getYear(), firstOfMonth.getMonth(), result );
        log( "The 3rd Friday of this month is : " + thirdFriday.format( "YYYY-MM-DD" ) );
    }

    /**
     * How many days till the next December 25?
     */
 
View Full Code Here

     * What day is 3 months and 5 days from today?
     */
    public static void whenIs3Months5DaysFromToday () {
        DateTime today = DateTime.today( TimeZone.getDefault() );
        DateTime result = today.plus( 0, 3, 5, 0, 0, 0, 0, DateTime.DayOverflow.FirstDay );
        log( "3 months and 5 days from today is : " + result.format( "YYYY-MM-DD" ) );
    }

    /**
     * Current number of hours difference between Paris, France and Perth, Australia.
     */
 
View Full Code Here

    /**
     * Format using ISO style.
     */
    public static void imitateISOFormat () {
        DateTime now = DateTime.now( TimeZone.getDefault() );
        log( "Output using an ISO format: " + now.format( "YYYY-MM-DDThh:mm:ss" ) );
    }

    public static void firstDayOfThisWeek () {
        DateTime today = DateTime.today( TimeZone.getDefault() );
        DateTime firstDayThisWeek = today; //start value
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.