File tree Expand file tree Collapse file tree
src/main/java/com/cronutils/example Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .cronutils .example ;
2+
3+ import com .cronutils .htime .HDateTimeFormatBuilder ;
4+ import org .joda .time .DateTime ;
5+ import org .joda .time .format .DateTimeFormatter ;
6+
7+ import java .text .SimpleDateFormat ;
8+ import java .util .Date ;
9+ import java .util .Locale ;
10+
11+ public class HTimeExamples {
12+ public static void main (String [] args ) {
13+ //You no longer need to remember "YYYY-MM-dd KK a" patterns.
14+ //we can create a formatter for JodaTime
15+ DateTimeFormatter jodatimeFormatter = HDateTimeFormatBuilder .getInstance ().forJodaTime ().getFormatter (Locale .US ).forPattern ("June 9, 2011" );
16+ System .out .println (jodatimeFormatter .print (DateTime .now ()));//formattedDateTime will be lastExecution in "dayOfWeek, Month day, Year" format
17+
18+ //or we can create a formatter for JDK time
19+ SimpleDateFormat jdkFormatter = HDateTimeFormatBuilder .getInstance ().forJDK12 ().getFormatter (Locale .US ).forPattern ("June 9, 2011" );
20+ System .out .println (jdkFormatter .format (new Date ()));//formattedDateTime will be lastExecution in "dayOfWeek, Month day, Year" format
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments