Permalink
Browse files

Add atDate()

Consistency in fluency
  • Loading branch information...
jodastephen committed Nov 30, 2012
1 parent b70444a commit c330c0733a3ebc680cbfeda575374cbffefc5f6b
Showing with 31 additions and 0 deletions.
  1. +15 −0 src/main/java/javax/time/LocalTime.java
  2. +16 −0 src/main/java/javax/time/OffsetTime.java
@@ -906,6 +906,21 @@ public LocalTime minusNanos(long nanosToSubtract) {
}
//-----------------------------------------------------------------------
+ /**
+ * Returns a local date-time formed from this time at the specified date.
+ * <p>
+ * This merges the two objects - {@code this} and the specified date -
+ * to form an instance of {@code LocalDateTime}.
+ * <p>
+ * This instance is immutable and unaffected by this method call.
+ *
+ * @param date the date to combine with, not null
+ * @return the local date-time formed from this time and the specified date, not null
+ */
+ public LocalDateTime atDate(LocalDate date) {
+ return LocalDateTime.of(date, this);
+ }
+
/**
* Returns an offset time formed from this time and the specified offset.
* <p>
@@ -760,6 +760,22 @@ public OffsetTime minusNanos(long nanos) {
return with(time.minusNanos(nanos), offset);
}
+ //-----------------------------------------------------------------------
+ /**
+ * Returns an offset date-time formed from this time at the specified date.
+ * <p>
+ * This merges the two objects - {@code this} and the specified date -
+ * to form an instance of {@code OffsetDateTime}.
+ * <p>
+ * This instance is immutable and unaffected by this method call.
+ *
+ * @param date the date to combine with, not null
+ * @return the offset date-time formed from this time and the specified date, not null
+ */
+ public OffsetDateTime atDate(LocalDate date) {
+ return OffsetDateTime.of(date, time, offset);
+ }
+
//-----------------------------------------------------------------------
@Override
public DateTime doWithAdjustment(DateTime dateTime) {

0 comments on commit c330c07

Please sign in to comment.