我想转换21022019为2019-02-21,但由于某种原因我无法转换。
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
public class StringToLocalDate {
public static void main(String[] args) {
System.out.println(convert("21022019"));
}
static LocalDate convert(String date) {
LocalDateTime ldt;
ldt = LocalDateTime.parse(date, DateTimeFormat.forPattern("YYYY-MM-dd"));
return LocalDateTime.now().toLocalDate();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 grep 命令返回超过 20 行。我需要显示从 grep 结果的最后一行开始的第 4 行,
假设我的文件有以下数据,
测试.txt
one
two
three
four
five
six
seven
eight
nine
ten
Run Code Online (Sandbox Code Playgroud)
任务是:
grep "nine" test.txt // i want seven as result
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?