-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.cronutils.example; | ||
|
||
import com.cronutils.htime.HDateTimeFormatBuilder; | ||
import org.joda.time.DateTime; | ||
import org.joda.time.format.DateTimeFormatter; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
public class HTimeExamples { | ||
public static void main(String[] args) { | ||
//You no longer need to remember "YYYY-MM-dd KK a" patterns. | ||
//we can create a formatter for JodaTime | ||
DateTimeFormatter jodatimeFormatter = HDateTimeFormatBuilder.getInstance().forJodaTime().getFormatter(Locale.US).forPattern("June 9, 2011"); | ||
System.out.println(jodatimeFormatter.print(DateTime.now()));//formattedDateTime will be lastExecution in "dayOfWeek, Month day, Year" format | ||
|
||
//or we can create a formatter for JDK time | ||
SimpleDateFormat jdkFormatter = HDateTimeFormatBuilder.getInstance().forJDK12().getFormatter(Locale.US).forPattern("June 9, 2011"); | ||
System.out.println(jdkFormatter.format(new Date()));//formattedDateTime will be lastExecution in "dayOfWeek, Month day, Year" format | ||
} | ||
} |