修改时间格式
This commit is contained in:
		
							parent
							
								
									3bf074c728
								
							
						
					
					
						commit
						05d6d81694
					
				| 
						 | 
				
			
			@ -12,6 +12,7 @@ import java.io.IOException;
 | 
			
		|||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.Paths;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.ZoneId;
 | 
			
		||||
import java.time.format.DateTimeFormatter;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.*;
 | 
			
		||||
| 
						 | 
				
			
			@ -260,7 +261,7 @@ public class GeneratorTestData {
 | 
			
		|||
                post.put("post_relationship", getRandomElement(Arrays.asList("转发", "评论", "引用", "原发")));;
 | 
			
		||||
                post.put("root_mid", postId);
 | 
			
		||||
                post.put("url", faker.internet().url());
 | 
			
		||||
                post.put("ip", faker.internet().ipV6Address());
 | 
			
		||||
                post.put("ip", faker.address().country());
 | 
			
		||||
                post.put("related_task", getRandomElement(Arrays.asList("美国大选", "关税大战", "俄乌冲突", "台海军演")));
 | 
			
		||||
                res.add(post);
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -307,7 +308,7 @@ public class GeneratorTestData {
 | 
			
		|||
                organization.put("name", faker.company().name());
 | 
			
		||||
                organization.put("foreign_name", faker.company().name());
 | 
			
		||||
                organization.put("establishment_time", getRandomDate());
 | 
			
		||||
                organization.put("address", faker.internet().ipV6Address());
 | 
			
		||||
                organization.put("address", faker.address().country());
 | 
			
		||||
                organization.put("leader", faker.name().username());
 | 
			
		||||
                organization.put("abbreviation", faker.name().username());
 | 
			
		||||
                organization.put("member_count", String.valueOf(faker.number().numberBetween(10000, 99999)));
 | 
			
		||||
| 
						 | 
				
			
			@ -395,11 +396,19 @@ public class GeneratorTestData {
 | 
			
		|||
        return list.get(new Random().nextInt(list.size()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static String getRandomDate() {
 | 
			
		||||
        LocalDateTime date = faker.date().past(365, 0,
 | 
			
		||||
                java.util.concurrent.TimeUnit.DAYS).toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
 | 
			
		||||
        return date.format(DateTimeFormatter.ISO_DATE_TIME);
 | 
			
		||||
    }
 | 
			
		||||
//    private static String getRandomDate() {
 | 
			
		||||
//        LocalDateTime date = faker.date().past(365, 0,
 | 
			
		||||
//                java.util.concurrent.TimeUnit.DAYS).toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
 | 
			
		||||
//        return date.format(DateTimeFormatter.ISO_DATE_TIME);
 | 
			
		||||
//    }
 | 
			
		||||
private static String getRandomDate() {
 | 
			
		||||
    LocalDateTime date = faker.date()
 | 
			
		||||
            .past(365, 0, TimeUnit.DAYS)
 | 
			
		||||
            .toInstant()
 | 
			
		||||
            .atZone(ZoneId.systemDefault())
 | 
			
		||||
            .toLocalDateTime();
 | 
			
		||||
    return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    private static void writeToCsv(List<Map<String, String>> data, String filename) {
 | 
			
		||||
        if (data.isEmpty()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -423,7 +432,7 @@ public class GeneratorTestData {
 | 
			
		|||
            writer.flush();
 | 
			
		||||
            log.info("写入文件: {}", filename);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            log.error("filename文件写入失败" + e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user