-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated joda-time from terasoluna-gfw-common and moved to new teras…
…oluna-gfw-jodatime project #224
- Loading branch information
Showing
30 changed files
with
1,752 additions
and
1,002 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
144 changes: 67 additions & 77 deletions
144
...rasoluna/gfw/common/date/DateFactory.java → ...a/gfw/common/date/ClassicDateFactory.java
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 |
---|---|---|
@@ -1,77 +1,67 @@ | ||
/* | ||
* Copyright (C) 2013-2014 terasoluna.org | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
package org.terasoluna.gfw.common.date; | ||
|
||
import java.sql.Time; | ||
import java.sql.Timestamp; | ||
|
||
import org.joda.time.DateTime; | ||
|
||
/** | ||
* Interface that creates current system date.<br> | ||
* <p> | ||
* create current system date as | ||
* </p> | ||
* <ul> | ||
* <li> | ||
* {@link org.joda.time.DateTime}</li> | ||
* <li> | ||
* {@link java.util.Date}</li> | ||
* <li> | ||
* {@link java.sql.Date}</li> | ||
* <li> | ||
* {@link java.sql.Timestamp}</li> | ||
* <li> | ||
* {@link java.sql.Time}</li> | ||
* </ul> | ||
*/ | ||
public interface DateFactory { | ||
/** | ||
* returns current system date as {@link org.joda.time.DateTime} in the default time zone. | ||
* @return current system date | ||
*/ | ||
DateTime newDateTime(); | ||
|
||
/** | ||
* returns current system date as {@link java.sql.Timestamp}. | ||
* @return current system date | ||
*/ | ||
Timestamp newTimestamp(); | ||
|
||
/** | ||
* returns current system date as {@link java.util.Date}. | ||
* @return current system date | ||
*/ | ||
java.util.Date newDate(); | ||
|
||
/** | ||
* returns current system date as {@link java.sql.Date}. | ||
* <p> | ||
* normalize hour,minute,second,milliSecond to 0. | ||
* </p> | ||
* @return current system date | ||
*/ | ||
java.sql.Date newSqlDate(); | ||
|
||
/** | ||
* returns current system date as {@link java.sql.Time}. | ||
* <p> | ||
* normalize year=1970,,month=1,day=1. | ||
* </p> | ||
* @return current system date | ||
*/ | ||
Time newTime(); | ||
} | ||
/* | ||
* Copyright (C) 2013-2014 terasoluna.org | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
package org.terasoluna.gfw.common.date; | ||
|
||
import java.sql.Time; | ||
import java.sql.Timestamp; | ||
|
||
/** | ||
* Interface that creates current system date.<br> | ||
* <p> | ||
* create current system date as | ||
* </p> | ||
* <ul> | ||
* <li> | ||
* {@link java.util.Date}</li> | ||
* <li> | ||
* {@link java.sql.Date}</li> | ||
* <li> | ||
* {@link java.sql.Timestamp}</li> | ||
* <li> | ||
* {@link java.sql.Time}</li> | ||
* </ul> | ||
*/ | ||
public interface ClassicDateFactory { | ||
/** | ||
* returns current system date as {@link java.sql.Timestamp}. | ||
* @return current system date | ||
*/ | ||
Timestamp newTimestamp(); | ||
|
||
/** | ||
* returns current system date as {@link java.util.Date}. | ||
* @return current system date | ||
*/ | ||
java.util.Date newDate(); | ||
|
||
/** | ||
* returns current system date as {@link java.sql.Date}. | ||
* <p> | ||
* normalize hour,minute,second,milliSecond to 0. | ||
* </p> | ||
* @return current system date | ||
*/ | ||
java.sql.Date newSqlDate(); | ||
|
||
/** | ||
* returns current system date as {@link java.sql.Time}. | ||
* <p> | ||
* normalize year=1970,,month=1,day=1. | ||
* </p> | ||
* @return current system date | ||
*/ | ||
Time newTime(); | ||
} |
158 changes: 78 additions & 80 deletions
158
.../gfw/common/date/AbstractDateFactory.java → ...ommon/date/DefaultClassicDateFactory.java
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 |
---|---|---|
@@ -1,80 +1,78 @@ | ||
/* | ||
* Copyright (C) 2013-2014 terasoluna.org | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
package org.terasoluna.gfw.common.date; | ||
|
||
import java.sql.Time; | ||
import java.sql.Timestamp; | ||
import java.util.Date; | ||
|
||
/** | ||
* Abstract implementation of {@link DateFactory}. | ||
* <p> | ||
* This class converts from {@link org.joda.time.DateTime} to {@link java.util.Date}, {@link java.sql.Timestamp}, {@link java.sql.Date}, | ||
* {@link java.sql.Time} <br> | ||
* so all things that concrete classes do is to return current {@link org.joda.time.DateTime}. | ||
* </p> | ||
*/ | ||
public abstract class AbstractDateFactory implements DateFactory { | ||
|
||
/** | ||
* Returns {@link java.util.Date} instance for the current date. | ||
* | ||
* @return Date current date | ||
*/ | ||
@Override | ||
public Date newDate() { | ||
return newDateTime().toDate(); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Timestamp} instance corresponding to current date and time. | ||
* | ||
* @return Timestamp current date | ||
*/ | ||
@Override | ||
public Timestamp newTimestamp() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToTimestamp(now); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Date} instance for the current date. | ||
* <p> | ||
* normalize hour,minute,second,milliSecond to 0. | ||
* </p> | ||
* | ||
* @return Date {@link java.sql.Date} instance for current date | ||
*/ | ||
@Override | ||
public java.sql.Date newSqlDate() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToSqlDate(now); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Time} instance for the current time. | ||
* <p> | ||
* normalize year=1970,,month=1,day=1. | ||
* </p> | ||
* @return Time {@link java.sql.Time} instance for current time | ||
*/ | ||
@Override | ||
public Time newTime() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToTime(now); | ||
} | ||
|
||
} | ||
/* | ||
* Copyright (C) 2013-2014 terasoluna.org | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
package org.terasoluna.gfw.common.date; | ||
|
||
import java.sql.Time; | ||
import java.sql.Timestamp; | ||
import java.util.Date; | ||
|
||
/** | ||
* Default implementation of {@link org.terasoluna.gfw.common.date.ClassicDateFactory}. | ||
* <p> | ||
* This class returns current system date. | ||
* </p> | ||
*/ | ||
public class DefaultClassicDateFactory implements ClassicDateFactory { | ||
|
||
/** | ||
* Returns {@link java.util.Date} instance for the current date. | ||
* | ||
* @return Date current date | ||
*/ | ||
@Override | ||
public Date newDate() { | ||
return new Date(); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Timestamp} instance corresponding to current date and time. | ||
* | ||
* @return Timestamp current date | ||
*/ | ||
@Override | ||
public Timestamp newTimestamp() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToTimestamp(now); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Date} instance for the current date. | ||
* <p> | ||
* normalize hour,minute,second,milliSecond to 0. | ||
* </p> | ||
* | ||
* @return Date {@link java.sql.Date} instance for current date | ||
*/ | ||
@Override | ||
public java.sql.Date newSqlDate() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToSqlDate(now); | ||
} | ||
|
||
/** | ||
* Returns {@link java.sql.Time} instance for the current time. | ||
* <p> | ||
* normalize year=1970,,month=1,day=1. | ||
* </p> | ||
* @return Time {@link java.sql.Time} instance for current time | ||
*/ | ||
@Override | ||
public Time newTime() { | ||
Date now = newDate(); | ||
return DateConvertUtils.convertToTime(now); | ||
} | ||
|
||
} |
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
Oops, something went wrong.