Skip to content

Commit 2346910

Browse files
committed
Use Java8 Time APIs
1 parent f3b111a commit 2346910

File tree

1 file changed

+7
-12
lines changed
  • doc-tool/src/dotty/tools/dottydoc/staticsite

1 file changed

+7
-12
lines changed

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ package dotty.tools
22
package dottydoc
33
package staticsite
44

5-
import java.nio.file.{ Files, FileSystems }
5+
import java.nio.file.{ Paths, Files, FileSystems }
66
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
77
import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInputStream }
88
import java.util.{ List => JList, Map => JMap, Arrays }
99
import java.nio.file.Path
1010
import java.nio.charset.StandardCharsets
11-
import java.util.Calendar
12-
import java.text.SimpleDateFormat
13-
import java.io.PrintWriter
14-
11+
import java.time.LocalDateTime
1512

1613
import com.vladsch.flexmark.parser.ParserEmulationProfile
1714
import com.vladsch.flexmark.parser.Parser
@@ -316,14 +313,12 @@ case class Site(val root: JFile, val projectTitle: String, val documentation: Ma
316313
*/
317314
val layouts: Map[String, Layout] = {
318315

319-
val cal = Calendar.getInstance()
320-
val today = cal.getTime()
321-
val currentHour = new SimpleDateFormat("hh").format(today)
322-
val currentMinute = new SimpleDateFormat("mm").format(today)
323-
val amOrPm = new SimpleDateFormat("a").format(today)
324-
val x = "<!-- generated on " + cal.get(Calendar.DATE) + "/"+ (cal.get(Calendar.MONTH)+1)+ "/"+cal.get(Calendar.YEAR) + " " + currentHour + ":" + currentMinute + ":" + amOrPm + "-->"
316+
val currentTime = LocalDateTime.now();
317+
val x = "<!-- generated on " + currentTime.getDayOfMonth() + "/"+ currentTime.getMonthValue()+ "/"+ currentTime.getYear() + " " + currentTime.getHour() + ":" + currentTime.getMinute() + ":" + currentTime.getSecond() + "-->"
325318
var loc = root.getAbsolutePath.toString + "/.." + "/doc-tool/resources/_layouts/main.html"
326-
scala.tools.nsc.io.File(loc).appendAll(x)
319+
if(Files.exists(Paths.get(loc))) {
320+
dotty.tools.io.File(loc).appendAll(x)
321+
}
327322

328323
val userDefinedLayouts =
329324
root

0 commit comments

Comments
 (0)