MENU

Convert any Java date/time string to Date or Calendar type

TOC

everyDateinterpoint (interword separation)timestring.java.util.Date, ,Calendarconversion to

Java can be used to create all kinds ofDate, time stringif possible. Calendar , , java.util.Date The following is a sample program that converts to the

Conversion requires formatting to the default date/time string and then Calendar type. If conversion is not possible, an IllegalArgumentException will be thrown.

Also,java.util.Date The getTime() method of the Calendar class is used for conversion to the

The date formats that can be converted are as follows

sample program



Execution Result

◆Example of Execution

◆Output result

----- Date only ---------------------------
[2007/01/01] = 'Mon Jan 01 00:00:00 JST 2007'
[2007-01-01] = 'Mon Jan 01 00:00:00 JST 2007'
[20070101] = 'Mon Jan 01 00:00:00 JST 2007'
[07-01-01] = 'Mon Jan 01 00:00:00 JST 2007'

----- Date + Time --------------------------
[2007/01/01 12:00:00] = 'Mon Jan 01 12:00:00 JST 2007'
[2007/01/01 12:00:00] = 'Mon Jan 01 12:00:00 JST 2007'
[2007/01/01 12:00] = 'Mon Jan 01 12:00:00 JST 2007'

----- time only ---------------------------
[12:00:00] = 'Wed Jun 06 12:00:00 JST 2007'

This sample program is a Chat&Messenger "Calendar and scheduling functionsThe actual use of the system is done in the "I'm a fan of this system.

TOC