当前位置: 首页>>代码示例>>Scala>>正文


Scala LocalDate类代码示例

本文整理汇总了Scala中java.time.LocalDate的典型用法代码示例。如果您正苦于以下问题:Scala LocalDate类的具体用法?Scala LocalDate怎么用?Scala LocalDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LocalDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: Rfc3339Util

//设置package包名称以及导入依赖的类
package de.zalando.play.controllers

import java.time.format.{ DateTimeFormatter, DateTimeParseException }
import java.time.{ LocalDate, ZoneId, ZonedDateTime }


object Rfc3339Util {

  private val fullDate = DateTimeFormatter.ofPattern("yyyy-MM-dd")
  private val shortDateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ")
  private val shortDTWithTicks = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
  private val fullDTWithTicks = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'")
  private val dateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSZ")

  def parseDateTime(datestring: String): ZonedDateTime =
    if (datestring.endsWith("Z") || datestring.endsWith("z")) parseFull(datestring)
    else parseParts(datestring)

  def parseDate(datestring: String): LocalDate =
    LocalDate.parse(datestring, fullDate)

  def writeDate(date: LocalDate): String = fullDate.format(date)

  def writeDateTime(date: ZonedDateTime): String = dateTime.format(date)

  private def parseParts(datestring: String): ZonedDateTime = {
    //step one, split off the timezone.
    val sepChar = if (datestring.indexOf('+') > 0) '+' else '-'
    val firstpart = datestring.substring(0, datestring.lastIndexOf(sepChar.toInt))
    val secondpart = datestring.substring(datestring.lastIndexOf(sepChar.toInt))
    //step two, remove the colon from the timezone offset
    val thirdpart = secondpart.substring(0, secondpart.indexOf(':')) + secondpart.substring(secondpart.indexOf(':') + 1)
    val dstring = firstpart + thirdpart
    try {
      ZonedDateTime.parse(dstring, shortDateTime)
    } catch {
      case pe: DateTimeParseException =>
        ZonedDateTime.parse(dstring, dateTime)
    }
  }

  private def parseFull(datestring: String): ZonedDateTime = {
    val z = ZoneId.systemDefault()
    try {
      ZonedDateTime.parse(datestring, shortDTWithTicks.withZone(z))
    } catch {
      case p: DateTimeParseException => ZonedDateTime.parse(datestring, fullDTWithTicks.withZone(z))
    }
  }

} 
开发者ID:LappleApple,项目名称:api-first-hand,代码行数:52,代码来源:Rfc3339Util.scala

示例2: Helpers

//设置package包名称以及导入依赖的类
import java.time.LocalDate


object Helpers {
  implicit class DateInterpolator(val sc: StringContext) extends AnyVal {
    def date(args: Any*): LocalDate = {
      // check args
      if (args.size != 3) throw new IllegalArgumentException("number of arguments should be 3")
      for (arg <- args) {
        if (!arg.isInstanceOf[Int]) {
          throw new IllegalArgumentException("arguments should be integers")
        }
      }

      // check parts
      if (sc.parts.size != 4) throw new IllegalArgumentException("illegal format")
      if (!sc.parts(1).equals("-") || !sc.parts(2).equals("-")) {
        throw new IllegalArgumentException("parts should be delimited by '-'")
      }

      val year = args(0).toString.toInt
      val month = args(1).toString.toInt
      val day = args(2).toString.toInt
      LocalDate.of(year, month, day)
    }
  }
}

object MyApp {
  def main(args: Array[String]) {
    print("Hello basic-project!")
    import Helpers.DateInterpolator
    val year = 2017
    val month = 1
    val day = 27
    val bd = date"$year-$month-$day"
    print(bd)
  }
} 
开发者ID:chibariyo,项目名称:sfi2e,代码行数:40,代码来源:DateInterpolator.scala

示例3: UnmarshallingDDirectivesSpec

//设置package包名称以及导入依赖的类
package akka.http.documenteddsl

import java.time.LocalDate

import akka.http.documenteddsl.directives.UnmarshallingDDirectives._
import akka.http.documenteddsl.documentation.OutDocumentation._
import akka.http.documenteddsl.documentation.{JsonSchema, OutDocumentation, RouteDocumentation}
import akka.http.scaladsl.model.{ContentTypes, StatusCodes}
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.MustMatchers._
import org.scalatest.WordSpec
import play.api.libs.json.{Format, Json}

class UnmarshallingDDirectivesSpec extends WordSpec with DDirectivesSpec with ScalatestRouteTest {
  import UnmarshallingDDirectivesSpec._

  "Out" must {
    val now = LocalDate.now()

    "be applied to route documentation" in {
      Out[TestOut].describe(RouteDocumentation()).out mustBe Some(OutDocumentation(
        success = List(
          Payload.Success(
            status = Status(StatusCodes.OK),
            contentType = "application/json",
            schema = JsonSchema.resolveSchema[TestOut],
            example = None))))
    }
    "be applied to route documentation (concatenated)" in {
      val out = Out(StatusCodes.Created, TestOut("id", Some("name"), now)) & Out(StatusCodes.NotFound, "entity not found")
      out.describe(RouteDocumentation()).out mustBe Some(OutDocumentation(
        failure = List(
          Payload.Failure(
            status = Status(StatusCodes.NotFound),
            contentType = None,
            description = Some("entity not found"))),
        success = List(
          Payload.Success(
            status = Status(StatusCodes.Created),
            contentType = "application/json",
            schema = JsonSchema.resolveSchema[TestOut],
            example = Some(Json toJson TestOut("id", Some("name"), now))))))
    }
  }

}

object UnmarshallingDDirectivesSpec {
  case class TestOut(id: String, name: Option[String], createdAt: LocalDate)
  implicit val testInFormat: Format[TestOut] = Json.format[TestOut]
} 
开发者ID:evolution-gaming,项目名称:akka-http-documenteddsl,代码行数:52,代码来源:UnmarshallingDDirectivesSpec.scala

示例4: Goal

//设置package包名称以及导入依赖的类
package teksol.mybank.domain.models

import java.time.LocalDate

import org.springframework.util.Assert
import teksol.domain.FamilyId
import teksol.infrastructure.{EventBus, ToJson}
import teksol.mybank.infrastructure.MyBankRepository

case class Goal(familyId: FamilyId,
                accountId: AccountId,
                goalId: GoalId,
                description: GoalDescription,
                dueOn: LocalDate,
                target: Amount,
                repository: MyBankRepository,
                eventBus: EventBus) extends ToJson {

    import teksol.infrastructure.Helpers._

    Assert.isTrue(target.isPositive, "target amount must be > 0")

    override def toJson: String =
        s"""{"family_id":${familyId.toJson},
           |"account_id":${accountId.toJson},
           |"goal_id":${goalId.toJson},
           |"description":${description.toJson},
           |"due_on":${dueOn.toJson},
           |"target":${target.toJson}}""".stripMargin.replaceAll("\n", "")
} 
开发者ID:francois,项目名称:family,代码行数:31,代码来源:Goal.scala

示例5: Entry

//设置package包名称以及导入依赖的类
package teksol.mybank.domain.models

import java.time.LocalDate

import teksol.domain.FamilyId
import teksol.infrastructure.{EventBus, ToJson}
import teksol.mybank.infrastructure.MyBankRepository

case class Entry(familyId: FamilyId,
                 accountId: AccountId,
                 entryId: EntryId,
                 postedOn: LocalDate,
                 description: EntryDescription,
                 amount: Amount,
                 repository: MyBankRepository,
                 eventBus: EventBus) extends ToJson {
    import teksol.infrastructure.Helpers._

    override def toJson: String =
        s"""{"family_id":${familyId.toJson},
           |"account_id":${accountId.toJson},
           |"entry_id":${entryId.toJson},
           |"posted_on":${postedOn.toJson},
           |"description":${description.toJson},
           |"amount":${amount.toJson}}""".stripMargin.replaceAll("\n", "")

} 
开发者ID:francois,项目名称:family,代码行数:28,代码来源:Entry.scala

示例6: MyBankAppService

//设置package包名称以及导入依赖的类
package teksol.mybank.domain.services

import java.time.LocalDate
import java.util.UUID

import teksol.domain.FamilyId
import teksol.infrastructure._
import teksol.mybank.domain.events.InterestPosted
import teksol.mybank.domain.models._
import teksol.mybank.infrastructure.MyBankRepository

class MyBankAppService(private[this] val repository: MyBankRepository, private[this] val eventBus: EventBus) extends EventBusConsumer {
    def findFamily(familyId: FamilyId): Option[Family] = repository.findFamily(familyId)

    def findAccount(familyId: FamilyId, accountId: AccountId): Option[Account] = repository.findAccount(familyId, accountId)

    def applyInterestsToAllFamilies(i18n: I18n, postedOn: LocalDate): Unit = {
        def publishInterestEntriesCreated(entries: Set[Entry]) =
            entries.map(entryToInterestPosted).foreach(eventBus.publish)

        def entryToInterestPosted(entry: Entry) =
            InterestPosted(entry.familyId, entry.accountId, entry.entryId, entry.postedOn, entry.amount)

        def buildEntriesForInterestBearingAccounts(accounts: Set[AccountWithInterest]) = {
            def buildDescription(account: AccountWithInterest) = {
                val formattedBalance = i18n.amountWithDelimiter(account.locale, account.balance)
                val formattedRate = i18n.numberToPercentage(account.locale, account.yearlyInterestRate)
                val i18nKey = account.balance match {
                    case Amount.ZERO => "interests.none"
                    case balance if balance.isNegative => "interests.negative"
                    case _ => "interests.positive"
                }

                i18n.translate(account.locale, i18nKey, params = Map("rate" -> formattedRate, "balance" -> formattedBalance)).map(EntryDescription.apply).get
            }

            accounts.map { account =>
                Entry(account.familyId, account.accountId, EntryId(UUID.randomUUID()), postedOn, buildDescription(account), account.interests, repository, eventBus)
            }
        }

        val accounts = repository.listAccountsAndTheirInterestRates
        val entries = buildEntriesForInterestBearingAccounts(accounts)
        repository.saveEntries(entries)
        publishInterestEntriesCreated(entries)
    }

    override def receive(event: Event): Unit = event match {
        case FamilyCreated(familyId, locale) => repository.saveFamily(Family(familyId, locale, repository, eventBus))
        case _ => () // do not react to other events: we're not interested
    }
} 
开发者ID:francois,项目名称:family,代码行数:53,代码来源:MyBankAppService.scala

示例7: SigningKeySpec

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.s3.auth

import java.time.LocalDate

import org.scalatest.{FlatSpec, Matchers}

class SigningKeySpec extends FlatSpec with Matchers {
  behavior of "A Signing Key"

  val credentials = AWSCredentials("AKIDEXAMPLE", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")

  val scope = CredentialScope(LocalDate.of(2015, 8, 30), "us-east-1", "iam")
  val signingKey = SigningKey(credentials, scope)

  it should "produce a signing key" in {
    val expected: Array[Byte] = Array(196, 175, 177, 204, 87, 113, 216, 113, 118, 58, 57, 62, 68, 183, 3, 87, 27, 85,
      204, 40, 66, 77, 26, 94, 134, 218, 110, 211, 193, 84, 164, 185).map(_.toByte)

    signingKey.key.getEncoded should equal(expected)
  }

  it should "sign a message" in {
    val sts =
      "AWS4-HMAC-SHA256\n20150830T123600Z\n20150830/us-east-1/iam/aws4_request\nf536975d06c0309214f805bb90ccff089219ecd68b2577efef23edd43b7e1a59"
    signingKey.hexEncodedSignature(sts.getBytes) should equal(
      "5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7"
    )
  }
} 
开发者ID:akka,项目名称:alpakka,代码行数:30,代码来源:SigningKeySpec.scala

示例8: decoder

//设置package包名称以及导入依赖的类
package io.gustavoamigo.quill.pgsql.encoding.range.datetime

import java.time.{LocalDate, ZonedDateTime, LocalDateTime}
import java.util.Date

import io.getquill.source.jdbc.JdbcSource
import io.gustavoamigo.quill.pgsql.encoding.GenericDecoder

trait Decoders extends GenericDecoder {
  this: JdbcSource[_, _] =>

  import Formatters._

  private val rangePattern = """([0-9\-\+\. :]+)""".r

  private def decoder[T](map: String => T) = decode(s => {
    val dates = rangePattern.findAllIn(s).toList
    (map(dates.head), map(dates.last))
  })

  implicit val dateTupleDecoder: Decoder[(Date, Date)] = decoder(parseDate)
  implicit val localDateTimeTupleDecoder: Decoder[(LocalDateTime, LocalDateTime)] = decoder(parseLocalDateTime)
  implicit val zonedDateTimeTupleDecoder: Decoder[(ZonedDateTime, ZonedDateTime)] = decoder(parseZonedDateTime)
  implicit val localDateTupleDecoder: Decoder[(LocalDate, LocalDate)] = decoder(parseLocalDate)
} 
开发者ID:gustavoamigo,项目名称:quill-pgsql,代码行数:26,代码来源:Decoders.scala

示例9: GroupedRow

//设置package包名称以及导入依赖的类
package unus.blocking

import java.sql.Timestamp
import java.time.{LocalDate, LocalDateTime}

import unus.db.{BlockedRow, Patient}
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.Dataset

case class GroupedRow(
                     key: String,
                     id: String,
                     patient: Patient
                     )

trait BlockerBase extends Serializable {
  val name: String

  def filterPair(p1: Patient, p2: Patient): Boolean = true
  def filter(r: Patient): Boolean
  def group(r: Patient): String = {""}
  def groupSplit(r: Patient): Seq[String] = {
    group(r) :: Nil
  }

  def anon1(r: Patient) = {
    groupSplit(r).map(rr => (rr, r))
  }

  def anon2(kv: (String , Iterable[Patient])) = {
    kv._2.map(r => GroupedRow(kv._1, r.enterpriseId, r))
  }

  def apply(rdd: RDD[Patient]): RDD[BlockedRow] = {
    val now = Timestamp.valueOf(LocalDateTime.now())
    val grouped = rdd.filter(r => filter(r))
        .flatMap(anon1)
        .groupByKey()
        .flatMap(anon2).keyBy(_.key).cache()

    grouped.join(grouped)
      .filter(r => r._2._1.id < r._2._2.id)
      .filter(r => filterPair(r._2._1.patient, r._2._2.patient))
      .map(r=> BlockedRow(name, r._2._1.id,r._2._2.id, now))
      .distinct()
  }
} 
开发者ID:mindfulmachines,项目名称:unus,代码行数:48,代码来源:BlockerBase.scala

示例10: DataFactorySpec

//设置package包名称以及导入依赖的类
package com.gilesc.mynab.finch.presenter

import java.time.LocalDate

import com.gilesc.mynab._
import com.gilesc.mynab.account.Banking

class DataFactorySpec extends TestCase
  with TestCaseHelpers
  with MockAccountCreation
  with MockTransactionCreation {

  val id = 0L
  val name = "hithere"
  val typ = Banking.toString

  val t = trans(1, LocalDate.parse("2017-03-19"), "Payee", "Major", "Minor", "Memo", 100, 0)
  val tr = Vector(PresentationData.transaction(t))
  val account = bankingWithId(id, name, Vector(t))

  val expected =
    """
      |{
      |  "id" : 0,
      |  "name" : "hithere",
      |  "type" : "Banking",
      |  "transactions" : [
      |    {
      |      "id" : 1,
      |      "date" : "2017-03-19",
      |      "payee" : "Payee",
      |      "category" : {
      |        "major" : "Major",
      |        "minor" : "Minor"
      |      },
      |      "memo" : "Memo",
      |      "withdrawal" : 100.0,
      |      "deposit" : 0.0,
      |      "cleared" : false
      |    }
      |  ]
      |}
    """.stripMargin

  "Data Factory" should "Convert correctly" in {
    PresentationData.account(account) should be(AccountData(id, name, typ, tr))
  }
} 
开发者ID:CraigGiles,项目名称:mynab,代码行数:49,代码来源:DataFactorySpec.scala

示例11: AddingTransactionsSpec

//设置package包名称以及导入依赖的类
package com.gilesc.mynab

import java.time.LocalDate

import com.gilesc.mynab.account._
import com.gilesc.mynab.category._
import com.gilesc.mynab.transaction._

class AddingTransactionsSpec extends TestCase
  with TestCaseHelpers
  with MockTransactionCreation
  with MockAccountCreation {

  "Creating a new transaction" should "add the transaction to the valid account" in {
    def mockSave(ctx: TransactionContext) = Right(TransactionId(1L))
    def mockFind(id: AccountId): Option[Account] =
      Option(bankingWithId(id.value, "Mocked Banking Account", Vector.empty[Transaction]))

    val accountId = 1L
    val date = LocalDate.now()
    val payee = Payee("Mock Payee")
    val category = Category(MajorCategory("Mock"), MinorCategory("Category"))
    val memo = Memo("Mock Memo")
    val deposit = Amount(BigDecimal(0.0))
    val withdrawal = Amount(BigDecimal(0.0))
    val cleared = Cleared(false)
    val ctx = TransactionContext(accountId, date, payee, category, memo, deposit, withdrawal, cleared)

    val transaction = Transaction.create(1L, ctx)
    val account = TransactionService.create(mockSave, mockFind)(ctx)

    account should be(
      Right(BankingAccount(1L, "Mocked Banking Account", Vector(transaction)))
    )
  }
} 
开发者ID:CraigGiles,项目名称:mynab,代码行数:37,代码来源:AddingTransactionsSpec.scala

示例12: Row

//设置package包名称以及导入依赖的类
package com.scalagen.data.api

import java.time.LocalDate

case class Row(protected[scalagen] val values: Seq[Any]) {
  def apply(i: Int): Any             = values(i)
  def get[@specialized T](i: Int): T = values(i).asInstanceOf[T]
  def getInt(i: Int): Int            = get[Int](i)
  def getFloat(i: Int): Float        = get[Float](i)
  def getDouble(i: Int): Double      = get[Double](i)
  def getLong(i: Int): Long          = get[Long](i)
  def getShort(i: Int): Short        = get[Short](i)
  def getBoolean(i: Int): Boolean    = get[Boolean](i)
  def getChar(i: Int): Char          = get[Char](i)
  def getByte(i: Int): Byte          = get[Byte](i)
  def getString(i: Int): String      = apply(i).toString
  def getDate(i: Int): LocalDate     = get[LocalDate](i)

  def map[@specialized T](f: Any => T): Row = Row(values.map(f))
  def mkString(sep: String): String         = values.mkString(sep)
  def zip[T](other: Seq[T]): Seq[(Any, T)]  = values.zip(other)
  def length: Int                           = values.length

  override def toString: String = values.mkString(", ")
}

object Row {
  def apply(size: Int): Row = new Row(new Array[Any](size))
} 
开发者ID:hntd187,项目名称:scalagen,代码行数:30,代码来源:Row.scala

示例13: RegressionResources

//设置package包名称以及导入依赖的类
package com.github.jancajthaml.workingday

import org.scalameter.api.{Measurer, Bench, Gen, exec}

import java.time.LocalDate

object RegressionResources extends Bench.OfflineReport {

  override def measurer = new Measurer.MemoryFootprint

  val times = Gen.range("times")(0, 100000, 20000)
  val calendar = WorkingDays(List(
    "Saturday",
    "Ressurection+5",
    "Ressurection-5",
    "Sunday",
    "1/1",
    "7/4/2017"
  ))
  val day = LocalDate.of(2017, 4, 26)

  performance of "com.github.jancajthaml.WorkingDays" in {
    measure method "is" in {
      using(times) config (
        exec.minWarmupRuns -> 2,
        exec.maxWarmupRuns -> 5,
        exec.benchRuns -> 5,
        exec.independentSamples -> 1
      ) in { sz => { (0 to sz).foreach { _ => { calendar.is(day) } } } }
    }
  }
}


object RegressionPerformance extends Bench.OfflineReport {

  val times = Gen.range("times")(0, 100000, 20000)
  val calendar = WorkingDays(List(
    "Saturday",
    "Ressurection+5",
    "Ressurection-5",
    "Sunday",
    "1/1",
    "7/4/2017"
  ))
  val day = LocalDate.of(2017, 4, 26)

  performance of "com.github.jancajthaml.WorkingDays" in {
    measure method "is" in {
      using(times) config (
        exec.benchRuns -> 20,
        exec.independentSamples -> 1,
        exec.outliers.covMultiplier -> 1.5,
        exec.outliers.suspectPercent -> 40
      ) in { sz => { (0 to sz).foreach { _ => { calendar.is(day) } } } }
    }
  }

} 
开发者ID:jancajthaml-scala,项目名称:working-day,代码行数:60,代码来源:Performance.scala

示例14: DateTimeUtils

//设置package包名称以及导入依赖的类
package uk.vitalcode.dateparser

import java.time.{DayOfWeek, LocalDate, LocalDateTime}

import scala.annotation.tailrec

object DateTimeUtils {

  def datesInRange(from: LocalDate, to: LocalDate, weekDays: Set[DayOfWeek] = Set.empty, dates: List[LocalDate] = Nil): List[LocalDate] = {
    if (to.isBefore(from)) dates
    else {
      val newDates = if (weekDays.isEmpty || weekDays(to.getDayOfWeek)) to :: dates else dates
      datesInRange(from, to.minusDays(1), weekDays, newDates)
    }
  }

  def getYearForNextMonthAndDay(month: Int, day: Int, currentTime: DateTimeProvider): Int = {
    getYearForNextMonthAndDay(month, day, currentTime.now)
  }

  private def getYearForNextMonthAndDay(month: Int, day: Int, currentTime: LocalDateTime): Int = {
    val currentMonth = currentTime.getMonth.getValue
    val currentDay = currentTime.getDayOfMonth
    if (currentMonth == month && currentDay == day) {
      currentTime.getYear
    }
    else getYearForNextMonthAndDay(month, day, currentTime.plusDays(1))
  }
}

trait DateTimeProvider {
  def now: LocalDateTime
}

class DefaultDateTimeProvider extends DateTimeProvider {
  override def now: LocalDateTime = LocalDateTime.now
} 
开发者ID:vitalcode,项目名称:date-time-range-parser,代码行数:38,代码来源:DateTimeUtils.scala

示例15: DateTimeInterval

//设置package包名称以及导入依赖的类
package uk.vitalcode.dateparser

import java.time.format.DateTimeFormatter
import java.time.{LocalDate, LocalDateTime, LocalTime}

import uk.vitalcode.dateparser.token.DateToken

case class DateTimeInterval(from: LocalDateTime, to: Option[LocalDateTime]) {
  def to(date: LocalDate, time: LocalTime): DateTimeInterval = copy(
    to = Some(LocalDateTime.of(date, time))
  )

  def to(year: Int, month: Int, day: Int, hours: Int = 0, minutes: Int = 0): DateTimeInterval = copy(
    to = Some(LocalDateTime.of(year, month, day, hours, minutes))
  )

  private def formatDate(date: LocalDateTime) = date.format(DateTimeFormatter.ISO_DATE_TIME)

  override def toString: String = s"interval[from: ${formatDate(from)}" + to.map(d => s" to: ${formatDate(d)}").getOrElse("") + "]"
}

object DateTimeInterval {

  val defaultTime = LocalTime.of(0, 0)

  def from(date: LocalDate, time: LocalTime): DateTimeInterval = new DateTimeInterval(
    from = LocalDateTime.of(date, time),
    to = None
  )

  def from(year: Int, month: Int, day: Int, hours: Int = 0, minutes: Int = 0): DateTimeInterval = new DateTimeInterval(
    from = LocalDateTime.of(year, month, day, hours, minutes),
    to = None
  )

  def of(dateTokens: List[DateToken], tp: DateTimeProvider): List[DateTimeInterval] = {
    val aggregatedTokens = aggregateTokens(dateTokens, tp)
    Analyser.analyse(aggregatedTokens)
  }

  def of(text: String, tp: DateTimeProvider = new DefaultDateTimeProvider): List[DateTimeInterval] = {
    val tokens = DateToken.parse(text)
    of(tokens, tp)
  }

  private def aggregateTokens(dateTokens: List[DateToken], timeProvider: DateTimeProvider): List[DateToken] = {
    val aggregatedTokens = DateTokenAggregator.aggregate(dateTokens, timeProvider)
    if (aggregatedTokens == dateTokens) aggregatedTokens
    else aggregateTokens(aggregatedTokens, timeProvider)
  }
} 
开发者ID:vitalcode,项目名称:date-time-range-parser,代码行数:52,代码来源:DateTimeInterval.scala


注:本文中的java.time.LocalDate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。