Skip to content

Commit

Permalink
Separated Joda-Time from org.terasoluna.gfw.common.date and moved new…
Browse files Browse the repository at this point in the history
… terasoluna-gfw-jodatime project #224
  • Loading branch information
making committed Dec 25, 2014
1 parent aea4867 commit d868d1a
Show file tree
Hide file tree
Showing 30 changed files with 1,517 additions and 1,002 deletions.
12 changes: 0 additions & 12 deletions terasoluna-gfw-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@
</dependency>
<!-- == End Google == -->


<!-- == Begin Joda-Time == -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<!-- == End Joda-Time == -->

<!-- == Begin AspectJ == -->
<dependency>
<groupId>org.aspectj</groupId>
Expand All @@ -87,10 +79,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
<!-- == End Jackson == -->

<!-- == Begin BeanValidation == -->
Expand Down
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();
}
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);
}

}
Loading

0 comments on commit d868d1a

Please sign in to comment.